Trying to run the [WSTP J/Link SampleProgram.java][1] Mathematica version file from the MacOS Sierra version 10.12.6 Terminal, generates "Exception in thread "main" ...

Updating to Oracle JDK 8u144 solved problem.


Assuming you have Mathematica installed in the default location, as /Applications/Mathematica.app, there is no need to adjust the command as given in the tutorial (the first one in your question). If you have Mathematica installed in some different location or using some other name, you need to adjust the name leading up to the .app. If you're not 100% sure where you are, using the "pwd" command to find the location.

Your problem is that your setting for -classpath is wrong, namely you are missing the .app between "Mathematica" and "/". You can add the missing .app, or you can use the relative path suggest in the linked tutorial.

| improve this answer | |
  • $\begingroup$ I used the "pwd" command, and location is /Part2 as indicated in terminal. Unadjusted command still returns the error. Adjusted command as stated, with or without the .app, still returns the error. Must be still something else. $\endgroup$ – ehounder Aug 27 '17 at 1:30
  • $\begingroup$ Mathematica was installed in the default location. Also added my system info above. The tutorial also says, "If you have your CLASSPATH environment variable set to include JLink.jar, then you can leave off the -classpath specification in these command lines." How might I set that, if it's something to try? $\endgroup$ – ehounder Aug 27 '17 at 15:05
  • $\begingroup$ Tried to set CLASSPATH environment with "set CLASSPATH=JLink.jar" then: java SampleProgram -linkmode launch -linkname '"/Applications/Mathematica.app/Contents/MacOS/MathKernel" -mathlink' ...same Exception errors. $\endgroup$ – ehounder Aug 27 '17 at 15:59
  • $\begingroup$ So, somewhere in the above screenshot, java command from directory holding .class and .java files is derailing the Wolfram Language kernel path from connecting /JLink.jar with .class .java returning: Exception in thread "main" java.lang.NoClassDefFoundError $\endgroup$ – ehounder Aug 28 '17 at 1:05
  • 1
    $\begingroup$ That sounds like you installation is damaged, or perhaps you have a very old version which still used Apple's java (but then I don't understand why the original command didn't work for you). I suggest you contact support at this point. $\endgroup$ – Itai Seggev Aug 28 '17 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.