Reputation: 51
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
Upvotes: 0
Views: 1707
Reputation: 42176
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.
Upvotes: 3