Pievis
Pievis

Reputation: 1994

NoClassDefFoundError running a .jar on linux

I'm having issue running a .jar I made on windows on ubuntu. I'm not really a linux user and I prefer to build my code from windows eclipse and then I make my tests on linux. When I execute my jar in linux I get the following exception generated by a missing .jar reference (I've used gson library class to convert some string to json).

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/Gson ...
Caused by: java.lang.ClassNotFoundException: com.google.gson.Gson

Now, after some researches online I found out where is the classpath directory and I copied the gson.jar into that folder, anyway I still get the error and I'm quite confused about all the classpath thing at this point.

Can somebody help me out?

Upvotes: 0

Views: 1330

Answers (1)

je_suis_beau
je_suis_beau

Reputation: 80

If you are using a manifest file to run the jar, be sure to specify the class path in the manifest file. Class-Path: LocationToGson.jar/gson.jar. Also, be wary of the fact that the Class-Path delimiter is not the same on both Windows and Linux for Java. In Linux, the java class-path delimiter is ':'

Upvotes: 2

Related Questions