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.
            Asked
            
        
        
            Active
            
        
            Viewed 2,396 times
        
    -3
            
            
        - 
                    enter you terminal command – Dhanasekaran Don May 31 '18 at 04:19
- 
                    Possible duplicate of [Including all the jars in a directory within the Java classpath](https://stackoverflow.com/questions/219585/including-all-the-jars-in-a-directory-within-the-java-classpath) – Venki WAR May 31 '18 at 04:22
2 Answers
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.
 
    