java - Shared Jar file between server and client -- NoClassDefFoundError -
im running debian java server needs send , receive objects of type eventobject , postobject (e.g serializable). these have been placed in .jar file sharedmodels.jar , used both in client , on server.
when trying compile on debian, output
serverthread.java:10: error: package models not exist import models.eventobject; ^ serverthread.java:11: error: package models not exist import models.postobject; ^ database.java:100: error: cannot find symbol arraylist<postobject> posts = new arraylist<>(); ^
on windows installation (eclipse), using
import models.eventobject; import models.postobject;
works fine (including external jar through eclipse).
how go making java understand infact these classes want use on debian?
i have added location of jar classpath in /etc/environment.
is there perhaps problem way jar structured? e.g. composed of package holds 2 classes?
regards , in advance
edit: made compile fine, when method called, server doesn't recognize class anymore. output:
exception in thread "thread-0" java.lang.noclassdeffounderror: models/postobject @ server.database.getposts(database.java:101) @ server.serverthread.run(serverthread.java:47) caused by: java.lang.classnotfoundexception: models.postobject @ java.net.urlclassloader$1.run(urlclassloader.java:372) @ java.net.urlclassloader$1.run(urlclassloader.java:361) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:360) @ java.lang.classloader.loadclass(classloader.java:424) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308) @ java.lang.classloader.loadclass(classloader.java:357) ... 2 more
i've understood because jvm recognize class @ compiletime not during runtime.. or wrong classpath. name of actual .jar need have naming fid package contained within? need fix this?
no. jars portable, there no difference between them. if work on windows, should work on linux, too.
your error message shows clearly, problem isn't bad jar, doesn't exist in classpath. there trivial problem in classpath setting, likely:
- is classpath syntax in
/etc/environment
valid? on windows, must separated:
, while on linux there;
. - you included directory of jar classpath, , not full path of jar?
/etc/environment
set in login shell, did log in / log out after that?
anyways, can give javac
-verbose
flag, show, try load jars from.
Comments
Post a Comment