I just recently started experimenting with the Mathematica J/Link extension, and decided to try and utilize a small custom Java class within Mathematica. The class is simple and runs perfectly well within Eclipse, but when I tried to follow the instructions for importing a Java class with J/Link at http://reference.wolfram.com/language/JLink/tutorial/CallingJavaFromTheWolframLanguage.html, I found that I kept getting the error:
**"A Java exception occurred: "java.lang.UnsupportedClassVersionError: \ MyClass : Unsupported major.minor version 52.0"**
The above error was the result of the LoadJavaClass function. The simple code I had used up to this point was as follows:
With /My/Project/Class/Path/ as the directory path to the class and MyClass as the .class file itself, respectively.
I'm currently running java version "1.8.0_25", Mathematica 10.0.1.0, and Eclipse 4.4.1, if any of that makes a difference.
Thank you to anyone who has a few minutes to help explain to me what I'm doing wrong and hopefully how to go about doing it correctly.
I found that you do not need to do the ReinstallJava:
This works and solves the problem:
InstallJava[CommandLine -> "/usr/bin/java"];
Tks Jean! It solver my problem too. Very useful.
Nobody seems to have replied to your post after 5 months. Did you eventually find a solution or just gave up? I am encountering the same problem with code that used to run just fine with Mathematica 8 and JDK 7 about 1.5 year ago.
Thank you in advance for any help or pointers.
I know it's silly and bad form to reply to my own post, but minutes after hitting the "Publish" button I found out that all I had to do was to point JLink to the correct location of the java executable. So, with the current versions of JDK 8, this gives:
ReinstallJava[CommandLine -> "/usr/bin/java"];
and then after that everything works fine for me.