I have seen alot of information about running processing with java using an IDE (eclipse, netbeans). I wanted to know how to run processing from java without using an IDE. Could someone describe step by step instructions in setting up and running processing from java or point me to a good website. I am using java 8 Thanks
Asked
Active
Viewed 1,503 times
0
-
Check this out http://stackoverflow.com/questions/14787093/how-to-run-processing-applications-from-the-terminal – Shank Jun 29 '16 at 16:08
-
That is running processing from a shell script. I want to run a .java file using processing as a package. – user3304639 Jun 29 '16 at 16:11
1 Answers
3
Step 1: Write Java code that uses Processing as a library. You can do this in any basic text editor. Here's a very basic example:
import processing.core.PApplet;
public class ProcessingTest extends PApplet{
@Override
public void settings() {
size(200, 200);
}
@Override
public void draw() {
background(0);
fill(255, 0, 0);
ellipse(100, 100, 100, 100);
}
public static void main (String... args) {
ProcessingTest pt = new ProcessingTest();
PApplet.runSketch(new String[]{"ProcessingTest"}, pt);
}
}
Save this code to a file named ProcessingTest.java
.
Step 2: Compile that file via the command prompt. Make sure to use the -cp
option to point to the Processing library jar file:
javac -cp path/to/Processing/core.jar ProcessingTest.java
That generates a file named ProcessingTest.class
.
Step 3: Run that .class
file via the command prompt. Again, make sure to use the -cp
option to point to the Processing library jar file:
java -cp path/to/Processing/core.jar ProcessingTest
To oversimplify a bit, an IDE is just handling the -cp
part for you and giving you a button to press to compile and run your code. But anything you can do in an IDE, you can do via the command prompt.

idleberg
- 12,634
- 7
- 43
- 70

Kevin Workman
- 41,537
- 9
- 68
- 107
-
I get the .java file compiled and then when i go to run the program it tells me: "Error: Could not find or load main class ProcessingTest". – user3304639 Jun 29 '16 at 18:33
-
@user3304639 You might have to include the path to `ProcessingTest` on the classpath as well. – Kevin Workman Jun 29 '16 at 18:42