We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Here is my MWE:
import java.lang.*;
import processing.core.PApplet;
public class test extends PApplet{
public static void main(String[]args){
PApplet.main("test");
}
public void settings(){
size(500, 500, P2D);
}
public void setup(){
background(255);
}
public void draw(){
ellipse(mouseX, mouseY, 50, 50);
}
}
I compile it with,
javac -classpath processing-3.3.7/core/library/core.jar test.java
It compiles without any warnings, or erros. But when I try to run it,
java test
I get the error,
Error: Could not find or load main class
What to do? I also tried adding class path when running, but it didn't help.
Answers
If you create a simple sketch in the PDE and then export it from there, you will see that you need other jar files. This is important specially when you are working with the P2D renderer.
Have you tried using processing-java to create your executable?
Before running the command, we need to implement the following changes:
Your main should look like this (From HappyCoding @KevinWorkman):
Now you execute:
Note that if you execute
javac -help
you will see some other convenient arguments Notice in Windows you use;
while in Linux you would use:
This should get you started.
Kf
Relevant posts:
http://happycoding.io/tutorials/java/processing-in-java
https://github.com/processing/processing/wiki/Command-Line
https://forum.processing.org/two/discussion/7375/how-to-compile-a-sketch-to-java
https://forum.processing.org/two/discussion/23924/handling-command-line-arguments-in-a-sketch
https://www.programcreek.com/2014/01/compile-and-run-java-in-command-line-with-external-jars/
https://rishisoftwareblog.wordpress.com/2013/02/12/compiling-and-executing-a-processing-sketch-as-a-java-class/
https://forum.processing.org/two/discussion/21204/using-launch4j-jarmatey-with-processing
http://launch4j.sourceforge.net/
https://github.com/processing/processing/tree/master/java/application/launch4j
adding
.:
to the beginning of the classpath helped. Nothing else need to be changed. Thanks.