# Problem trying to compile JLink application

I have no trouble compiling and running the sample Java to Mathematica program SampleProgram.java that can be found in the Wolfram installation:

FileNames["SampleProgram.java", {\$InstallationDirectory}, Infinity]


When I try to compile and run a modified copy of this program from a different directory I get the following error message:

Error: Could not find or load main class files.wolfram


It seems it should be looking for com.wolfram.jlink.*. I am quite sure the classpath to JLink.jar is correct.

Does JLink.jar contain a manifest pointing to some other resource that it cannot find?

• That really sounds like a classpath issue even though you've checked it. If you don't modify the program and run it from the other location, does it work? Does the modified program work in the Wolfram directory tree? Are you having problems running javac (compiling) or java (running)? -- (no, there is no reference to files.wolfram in the manifest.) Oct 1, 2015 at 5:34
• @John Are you no longer interested in your question? I mean, why do you give a bounty on a question and then never show up to discuss your problem? Oct 7, 2015 at 19:55
• @halirutan I was trying to help a student with a project. The issue did not occur on the student's computer. So we have moved beyond this as an emergency issue. Oct 9, 2015 at 10:36

Unless you tell us exactly what you typed on the commandline, there is no way of knowing what went wrong.

Let me give you a head-start. My Mathematica installation is in the directory

/usr/local/Wolfram/Mathematica/10.2


Therefore, to start the SampleProgram I go into the directory where SampleProgram.class is and type

java -classpath \


and I get the following output

2 + 2 = 4
3 + 3 = 6
4 + 4 = 8


If you are working on Windows, then your command should look like

java -classpath ".;\path\to\JLink.jar"