Hi,
I am trying to pack this into a JAR file with IntelliJ IDEA (I can also change IDE if needed, but I d rather stick to this).
The project runs in the IDE if I run the file. Honestly, I don’t really know which is the entry point!
package main.com.test;
import processing.core.PApplet;
public class MyMain extends PApplet {
public void settings() {
size(500, 500);
}
public void draw(){
background(64);
ellipse(mouseX, mouseY, 20, 20);
}
public static void main (String... args) {
MyMain pt = new MyMain();
runSketch(new String[]{"myMain"}, pt);
}
Following this guide [1] I created a Manifest file and added the processing library -that is exported into the correct folder under core.jar -
Manifest-Version: 1.0
Main-Class: main.com.test.MyMain
and the built the artifact (Build-> Artifacts) in IntelliJ
then from terminal run and obtain
$ java -jar out/artifacts/TestJar/archive.jar
Error: Could not find or load main class main.com.test.MyMain
I am sure it’s a stupid problem but I spent the last 5 hours of my life trying this and I am very frustrated.
Thanks,
Alessio
[1] Creating an Executable JAR in Intellij IDEA | Karthic Raghupahti
A more stable way to work is to use maven, then your not reliant on ide. Further I would expect your sketch to look like this:-
package main.com.test;
import processing.core.PApplet;
public class MyMain extends PApplet {
public void settings() {
size(500, 500);
}
public void draw(){
background(64);
ellipse(mouseX, mouseY, 20, 20);
}
static public void main(String[] passedArgs) {
String[] appletArgs = new String[] { "main.com.test.MyMain" };
if (passedArgs != null) {
PApplet.main(concat(appletArgs, passedArgs));
} else {
PApplet.main(appletArgs);
}
}
}
Note the package name prefix in appletArgs. Now processing does not officially release maven artifacts, which is unfortunate, but there’s nothing stopping you creating your own (core.jar would be a start). The latest version available from maven central is 3.3.7 which might be good enough.
See snippet below showing part of pom.xml to create a main manifest using maven.
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>main.com.test.MyMain</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
1 Like
Hi,
thanks a lot for your answer and time. From your suggestion to use a general framework I understood something important:
I should not use the Java interface to the Processing library if I have no idea about how Java works and I am not interested in it!
Indeed, I have no idea what else to write in the pom.xml file and the difference between a maven artifact and the core.jar file in the library folder.
Hence, I opened the code from the processing ide. -Which is not as pleasant and helpful as the IntelliJ ide-. Changet slightly the code. And run the ¨Export Application¨ in File.
Et voila´ I have the application in exe and bush files. Thank you, Processing developers, to make it easy.
The code is accessible from this shared folder till 1 May 2021
1 Like
Aww Man, that is awesome. I tried this oscilloscope a few months ago to understand the PPM signal of my RC receiver. It was a big help, thanks. It is a surprise to see it on this forum, but it is written in processing afterall.
EDIT: Wow, I unzipped the wrong application.linux64.zip and it was that oscilloscope. I unzipped your application and it’s still awesome. I like the graph. Nice. I assume e has something to do with population growth and stability.
1 Like