-3

I am running Java program from command line. I am referring to only 1 external jar file. i have added entire path to that jar in classpath. even then i get no class def found error while running program in command line. Program compiles without any error.

Gayatri
  • 3
  • 4

2 Answers2

1

I think you complied and run the Java program like this

javac -cp fullyqualifiedPathToExternalJar yourfilepath/filename.java
java -cp fullyqualifiedPathToExternalJar yourfilepath/filename

This is totally wrong. When you compiled and run in this manner program compile successfully but not run. This because you have to follow the syntax of java command Properly.

for compiling its Ok.

javac -cp fullyqualifiedPathToExternalJar yourfilepath/filename.java

To run the program you have to add your file path to the classpath:

java -cp fullyqualifiedPathToExternalJar;yourfilepath filename.java //in windows
java -cp fullyqualifiedPathToExternalJar:yourfilepath filename.java //in linux

The syntax is

javac example.java
java example

with folderpath

javac /home/admin/example.java
java -cp /home/admin example//only class name
Dhanasekaran Don
  • 294
  • 1
  • 14
0

Might be the chances of jar's compatibility issue. check yous inter dependent jar versions.