1

I try to export my processing app as the "ready to use" application with exe launch file for desktop. My code is pretty simple. Proccessing code:

//import io.itch.mgdsstudio.airfight.connecteddevices.*;
private io.itch.mgdsstudio.airfight.connecteddevices.Controller controller;   
       
void setup(){   
  size(600,800,  JAVA2D);
   background(0);
   //I think the next code line can not be launched after export. Background stays black
   controller = new io.itch.mgdsstudio.airfight.connecteddevices.Controller(this);
}

void draw(){      
  controller.render();        
}

and the java-class:

package io.itch.mgdsstudio.airfight.connecteddevices;
import processing.core.PApplet;

public class Controller {
   private PApplet engine;

    public Controller(PApplet engine) {
       this.engine = engine;
    }
   
    public void render(){
        engine.background(255,0,0);        
    }
}

The application runs perfect from processing ide - the screen is red. But after export it can not run properly. The screen is black. I tested processing 3 and 4. In january I exported an another application succesfully. But now I can not launch exported file. I think the trouble is in versions of the java source files.

I tried to change code so:

import io.itch.mgdsstudio.airfight.connecteddevices.Controller;
private Controller controller;   

void setup(){   
  size(600,800,  JAVA2D);
   background(0);   
   controller = new Controller(this);
}

void draw(){      
  controller.render();        
}

I receive the message in the console: No library found for io.itch.mgdsstudio.airfight.connecteddevices but it runs in the ide. But after export it can not run properly again. Maybe i need another package names?

  • I'm not familiar with the Controller library you're using: can you please point me to it ? Is it a Processing wrapper library or a .jar file you drop onto your Processing sketch ? Does removing `private` change anything ? Overall it sounds like Processing's Export Application feature is failing to copy the Controller library jar file to the library folder adjacent to the exe. Have you tested exporting with (or without) the `Embed Java` option in Export Options ? Do you need to export the exe to easily distribute your sketch (or do you only need to run it on your computer, but launch it easily) – George Profenza Feb 15 '23 at 09:39
  • Controller is not a library. It is only a single java file that lays in the same directory as the main pde file. I export with embedded java - without it the exported .exe can not be opened. – Alexander Gorodilov Feb 15 '23 at 11:04
  • Maybe in the previous time when I exported my another project I packed the Java compiled classes into a library with jar extension and added to the project not as the Java sources but as Java compiled in the library. I have forgot it. It is a method to export but I can not understand why simply added Java source files can not be exported and the application with them can not run without pde. – Alexander Gorodilov Feb 15 '23 at 13:21
  • It's a valid question. I would expect using a .java file in your Processing project to work. (I'm not sure if the package is causing issues (as using the editor has a few limitations (I bumped into some issues using `static`)). Would you be able to share the contents of the .java file so it's easy to replicate your issue ? Alternatively, have you tried using `processing-java` as an alternative ? (e.g. if `processing-java` (sibling with processing.exe) is added to the `%PATH%` environment variable) then `processing-java --sketch=path\to\YourSketchFolder --run`) – George Profenza Feb 15 '23 at 16:00
  • The content is published in the question. One method, one constructor and one field. I didn't tested with processing-Java. What's is the difference? – Alexander Gorodilov Feb 15 '23 at 20:39
  • My bad, missed the code right in front of me :) It looks like it's the `package` statement. – George Profenza Feb 15 '23 at 23:21

1 Answers1

0

There seems to be an issue/bug using package inside the Processing IDE.

As you hinted in your comments, if you could compile a .jar in your Java IDE of choice and use that in Processing that should work.

From a pragmatic point of view, if you don't plan on fixing the Processing IDE to handle package as expected, you can simply not use it your code:

import processing.core.PApplet;

public class Controller {
   private PApplet engine;

    public Controller(PApplet engine) {
       this.engine = engine;
    }
   
    public void render(){
        engine.background(255,0,0);        
    }
}
Controller controller;
       
void setup(){   
  size(600,800,  JAVA2D);
   background(0);
   controller = new Controller(this);
}

void draw(){      
  controller.render();        
}

This wouldn't be convenient on a larger project where you may want to write Java code in your preferred IDE but still be able to colaborate with others that use the Processing IDE alone.

Since running in the Processing IDE works (e.g. dev/testing), but can't export a .exe for easy deployment, a workaround could be using the processing-java command. (If you add your Processing installation folder to the Windows %PATH% environment variable you should be able to type processing-java in a new Command Prompt window and see the help/usage guide).

Running processing-java --sketch=path\to\YourSketchFolder --run should run the sketch the same way the Processing IDE does (without actually having the IDE open). While this implies installing Processing and adding it to %PATH% on any new machine on one hand, on the other it saves you the time of having rebuild/repackage new .exe files for every single change.

George Profenza
  • 50,687
  • 19
  • 144
  • 218
  • The customer has no processing on his raspberry pi. And I think he should not have it and should not have java. He should get the standalone application and be able to launch it by simple double click. I think also that it is a bug of the export manager, but I like this export ability from processing, that creates in two clicks the launchers for every platform with embedded java – Alexander Gorodilov Feb 16 '23 at 13:22
  • I had no idea this was meant to be deployed on a Raspberry PI. (Hopefully it's a newer/faster one as Java drains a lot of resources on a limited system like that). Unfortunately I won't have the time to dig deeper. Here are few options: 1. you can file an issue on the [official repo](https://github.com/processing/processing4) (might not be a fast option). 2. download the repo and try to find how the editor handles `package` so you could fix the issue yourself (could be faster). 3. use a script that processes the .java file when adding in Processing to remove the usage of `package`... – George Profenza Feb 17 '23 at 00:25
  • ...alternatively, look at what tools can be integrated into your ide (e.g. ant tasks, shell scripts/etc.) that would allow you to "port" the export application functionality from the Processing IDE to your preferred IDE. (For example there was an eclipse plugin called [Proclipsing](https://github.com/ybakos/proclipsing) which made it easy to make PApplet based Java projects, integrate Processing libraries as well as export application. Hopefully it still works). It depends on your level of comfort with code, what IDE you already use and what your overall goal is. Hope this helps. – George Profenza Feb 17 '23 at 00:30
  • 1
    Thanks, you can forget the goal platform: it is not matter. The exported application can not be launched also on a windows PC. I think also that this is a bug in the processing IDE. Maybe I can repair it, but the fastest way is to pack all the compiled classes using Intellij IDEA artefacts in a jar file and append it to a clear processing project as the library. I don't need export to Eclipse. – Alexander Gorodilov Feb 19 '23 at 10:33
  • ... I create my projects from begin using Intellij IDEA and than export they in processing only for comfortable export for the goal platforms the customers without preinstalled jre - Windows, Raspbian OS 32 bit and Raspbian OS 64 bit. – Alexander Gorodilov Feb 19 '23 at 10:34
  • Sounds like you've got a solution there creating a .jar file for your classes :). Just to clarify, I didn't say you need Eclipse. The Proclipsing plugin makes it easy to export an app from that IDE. The idea was to check if there's a similar Intellij IDEA Processing plugin that can do the app export from there directly (without needing the Processing IDE just for the .exe export). I did a quick search and nothing came up, so someone would need to develop an IntelliJ IDEA Processing app exporter plugin to make this easier on the longer run. Pragmatically: you know your project, time and skills. – George Profenza Feb 20 '23 at 21:57