Closed eacousineau closed 5 years ago
Ah, looks like a major / minor version issue. I added a quick main()
method and was able to execute the jar from the bench_matlab_ops
directory:
$ java net.apjanke.matlab_bench.bench_nops.DummyJavaClass
Running it with Matlab's Java version reveals that it is incompatible with my system's. Awesome haha.
$ $MATLAB_ROOT/sys/java/jre/glnxa64/jre/bin/java net.apjanke.matlab_bench.bench_nops.DummyJavaClass
Exception in thread "main" java.lang.UnsupportedClassVersionError: net/apjanke/matlab_bench/bench_nops/DummyJavaClass : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: net.apjanke.matlab_bench.bench_nops.DummyJavaClass. Program will exit.
I've gotta stop for a while, but if I'm able to return to this, I'll see how easy it is to recompile with a version compatible with Matlab (without screwing over my security).
Oops... I forgot I had JDK 1.8 installed on my machine, and I used its javac
to compile this, and Java 1.8 class files are not necessarily back-compatible. I'll recompile to an older JVM target for wider compatibility.
I've recompiled the Java classes with JDK 1.6 and checked them in. (https://github.com/apjanke/matlab-bench/commit/a87f8738546c92c727e120aef61612c4d337a482) Should work now. I've added a main() for testing and was able to reproduce the problem with the old class file.
Works for me now using a standalone 1.6 JRE. I don't have the older version of Matlab to test it in that environment, but this should be sufficient. Let me know if it doesn't work.
[@ in ~/Dropbox/satchel/projects/Matlab/matlab-bench/bench_matlab_ops on ⇄ master]
$ java -cp . net.apjanke.matlab_bench.bench_nops.DummyJavaClass
Hello, world!
[@ in ~/Dropbox/satchel/projects/Matlab/matlab-bench/bench_matlab_ops on ⇄ master]
$ /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -cp . net.apjanke.matlab_bench.bench_nops.DummyJavaClass
Hello, world!
[@ in ~/Dropbox/satchel/projects/Matlab/matlab-bench/bench_matlab_ops on ⇄ master]
$
Closing as fixed.
Trying to run the code (sha: 6059d52), but I get the following error:
Will try and dig a bit and see what issue it is.
System: