How can i make this code into a standalone jar file, that can be executed to just work.
(i want to use this to put on a server, which only supports jar files)
I already tried compiling processing code to a jar file which didnt work.
I know how to create a java class file & run it but when i try to make processing into one file it doesnt work.
I wish processing would just directly compile in either one exe or just a jar… ;-;
Note that I’m new to this game. Does it have to be a jar file?
How?
I’ve just tested it in Processing 4.2 on a Windows system. I used file → export application and selected both Windows and Linux which resulted in the following (it does not result in a jar file but an executable).
Windows
Linux
Running the exe on Windows worked as expected. You can remove the source directory as far as I know.
When you export a file in Processing it puts the compiled app inside a folder in your sketch folder. Inside the app folder should be a .java file of your project. Have you tried converting the .java file to a .jar file? The conversion process uses the command line and is found with a Google search.
would you please elaborate a bit more what you’re trying to achieve ?
If you export for linux your jar is already generated by the exporter beside the dependent libs.
$ jar -tf ExportExample/linux-amd64/lib/ExportExample.jar
META-INF/MANIFEST.MF
ExportExample.class <---------------- HERE ------
look into it shows the used function on higher level.
$ javap ExportExample.class
Compiled from "ExportExample.java"
public class ExportExample extends processing.core.PApplet {
public ExportExample();
public void setup(); <---------------- HERE ------
public void draw(); <---------------- HERE ------
public void settings();
public static void main(java.lang.String[]);
}
in more detail the draw function (for relevant calls):
What I am trying to achieve is having a processing sketch in a one file jar.
I followed both tutorials which someone sent me In this thread, but none of the worked.
When I try to open the jars, that come when exporting the code to Linux, I go to the lib folder and try running all jars at the same time - doesn’t work. Command line - doesn’t work, gives me errors on class could not be found.
In the file called what you named the sketch is bash code and it opens jogl-all.jar, gluegen.jar, core.jar & nameofthesketch.jar
When running this bash script it will open the sketch fine.
My question is, how do I convert everything in the “linuxamd64” folder to just one beautiful jar file that when klicked opens the windows, just like running the bash file in the command prompt.
It needs to be one jar file. That’s my question, I hope I explained it good enought
Ahh! Ok! Understood…
In principle that isn’t really a hard challenge, if you know how java jar’s work.
Starting on the stage after export application already done
I made an example video to show …
Just keep in mind that you need a proper working X11 Environment.
For stuff like fancy opengl etc you need to set the *.so available to your java-lib directory.
But for simple cases the steps in the video should be sufficient …
Your answer (which you’ve marked as solution ) is not correct !?
The bash script can be used on Linux but also on windows if you’ve bash installed by ie. WSL, cygwin, git-bash, etc.
That’s also not true as you’ve the required commands (java, jar) already rolled out by processing itself. But for sure you need to point to it, by either use an absolute path or set it in your PATH environment variable…
Also the question marks only needed if your sketch would have any fancy names with blanks or hyphens, etc.
Cheers
— mnse
PS: please consider to mark the post which pointing you to a possible solution as solution and not your “fix”.