Not sure of how do you want it to work in your case, or if @GoToLoop already answered what you needed to know.
You could compile your .java files from Idea, exporting a jar file that you can use from the Processing IDE.
It can also be done like this.
- I write two sample java files:
// mylib/src/Bar.java
package com.hamoid;
public class Bar {
public static int sumUp(int a, int b) {
int i = a + b + 100;
return i;
}
}
// mylib/src/Sum.java
package com.hamoid;
public class Sum {
public static int sumUp(int a, int b) {
int i = a + b;
return i;
}
}
-
In the terminal, go into that folder
cd mylib -
Compile the java files into class files:
javac -bootclasspath /usr/lib/jvm/default/jre/lib/rt.jar -source 1.6 -target 1.6 -d . -classpath /usr/share/processing/core/library/core.jar src/*.java
There are two paths to figure out there: one is the path tort.jarwhich varies depending on your OS. The other one you may need is the path to Processing’score.jarbut that’s only if your java files make use of PApplet or other Processing classes. If not you can remove-classpath....core.jar. -
Pack the the class files into a jar file:
jar -cf all.jar com/
I used com/ because that’s the folder that was created in step 3, since my two java files are inside packagecom.hamoid. -
Then I create a Processing sketch with these files:
Test.pde
code/all.jar
The content of Test.pde is this:
import com.hamoid.*;
println(Sum.sumUp(2, 5));
println(Bar.sumUp(2, 5));
- Remember to put
all.jarinside thecode/folder in the sketch.
If I run it it prints this:
7
107
I hope this helps you a bit in your quest 