Forums > Java

first steps with java in Max… I falled wow!

February 21, 2011 | 7:20 pm

hello,
beginning to use java in max.
I read a lot but I probably missed something.

my classpath has been modified.
my specific folder where I put the jar I want to use is correctly typed and the considered jar is loaded.

BUT, I have a stupid problem.
I want to call some methods & objects so I created a pretty nice very minimal test.java code.
I put it in the folder where the patch sits.
In my patch, [mxj test]
here is the result
Could not load class 'test'

of course, there isn’t at this point a .class

what is my stupid error …?

all infos would be … appreciated :)


February 21, 2011 | 8:54 pm

Two steps missing:
The Java code must be compiled by java compiler into the java executable code ".class" file, an actual binary file produced by the java compiler (usually called javac).. you can do this with the max mxj java editor which can call the commandline javac command for you, OR with your Java dev environment "IDE" of choice: eclipse, Xcode, IntelliJ, NetBeans…
2) Once the Java is compiled ( you will have to find and correct errors in file before it compiles, right,:) ? ), you place the resulting file somewhere in the running java’s classpath, the cycling74/java/lib dir, for instance. Then the mxj object can find the code. So, compiling myJava.java produces myJava.class, place that in mxj lib folder, go to max create [mxj MyJava] : boom! u should be home free.

so, 1)compile Java
(if you’re lost, use the simple java editor, it can call the javac compile for you correctly.)
2) Copy .class file to dir on java classpath.
3) execute [mxj myJava].

Hope this helps.
cfb aka j2k


February 21, 2011 | 9:00 pm

ok, it is very clear :)
thanks.

max mxj java editor = quickie, right?
I cannot figure out how to compile inside quickie.

imagine I want to create test.java
I create the file inside my patch folder.
I create [mxj quickie test] … first error in loading the "class"
I send viewsource message, it opens quickie.java file. I modify it, resave it under the name test.java
… all the same

I’m cursed :p


February 22, 2011 | 9:12 am

Once you opened your source with the viewsource message, you can compile it in the editor: in the editor’s Java menu, choose "Open Compile Window", check the different fileds (you probably don’t need to put anything in the Compiler options), and click the "Compile" button.


February 22, 2011 | 9:19 am

I cannot even open the source
Does the folder where the patch is already is contained in path?


February 22, 2011 | 9:44 am

Create an mxj instance, open its help file, then click viewsource.
Once the Java editor is launched, go to File Menu, choose Open and open your .java file.

Then you can compile it.


Viewing 6 posts - 1 through 6 (of 6 total)