Getting Started With Java

j kuprys's icon

Hi,

I've got a patch built on Javascript from my Masters Thesis; it runs well enough but I want to push it further. Sadly, the performance is holding it back so I'd like to translate it to Java. The script by itself isn't anything too complex, it's mostly just pulling data and doing horrendous amounts of math. I'm reading up on Java and trying to teach myself, but atm I'm struggling to get any Java class to run in Max MSP.

I'm consulting the documentation for Max-MXJ that comes with the package to figure out how to work with the mxj object and translate my script, but whenever I try to compile a simple hello world message I get the error:

java.lang.UnsupportedClassVersionError: bongo has been compiled by a more recent version of the Java Runtime (class file version 63.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at com.cycling74.max.MXJClassLoaderImpl.doLoadClass(MXJClassLoaderImpl.java:117)
at com.cycling74.max.MXJClassLoader.loadClazz(MXJClassLoader.java:88)

To my understanding, it's telling me that the compiler version I've been using is wrong, yet I'm running the latest JavaSE version. Having looked up the class file versions, 52 would imply JavaSE 8?


My question is this: Should I just downgrade my local version of JavaSE or is there some trick I'm missing here? Any further advice on working with Java in Max MSP would be appreciated!

I'm running Win10 and the latest version of Max MSP if that makes any difference.

Thank you and all the best!

volker böhm's icon

<quote>My question is this: Should I just downgrade my local version of JavaSE or is there some trick I'm missing here? Any further advice on working with Java in Max MSP would be appreciated!
</quote>
This shouldn't be necessary. Depending on the IDE you're using, you should be able to select an older JRE version to work with. We just managed to get it running on a student's windows laptop the other day, using Eclipse (Project Properties > Java Build Path) - if I remember well, we had to go back to JRE 1.6.
hth

Tim Moore's icon

The Java compiler supports options to build classes that are compatible with older runtime versions. If you're compiling using javac on the command line, you can pass the option '-target 8'.