0

I have a java source file named File_2.java that starts with import Jama.*; and it contains the main method.
The current directory contains java source file File_2.java and the Jama-1.0.3.jar file

I can compile the source File_2.java using

javac -classpath Jama-1.0.3.jar File_2.java

This generates a File_2.class file in the current directory which is not getting executed. I have tried the following

$ java File_2
Exception in thread "main" java.lang.NoClassDefFoundError: Jama/Matrix
at File_2.main(File_2.java:32)

and

$ java -classpath Jama-1.0.3.jar File_2
Error: Could not find or load main class File_2

Thus my question is how do I execute the File_2.class file ? Kindly help.

moki
  • 3
  • 2

1 Answers1

2

You have to add your current directory to in order to find your class file.
You must run java -classpath Jama-1.0.3.jar:. File_2.

delca85
  • 1,176
  • 2
  • 10
  • 17
  • I am getting `Error: Could not find or load main class :.` – moki Apr 01 '17 at 03:30
  • Are you sure you aren't adding a space after colon? You have to write exactly `java -classpath Jama-1.0.3.jar:. File_2` or `java -cp Jama-1.0.3.jar:. File_2`. The dot after colon is used in order to add your .class file to your classpath. – delca85 Apr 01 '17 at 05:08
  • It works. There was a space appearing before colon (due to tab completion). Thanks. – moki Apr 01 '17 at 06:09