cancel
Showing results for 
Search instead for 
Did you mean: 

NoClassDefFoundError when not in Eclipse

Former Member
0 Kudos

I developed a standalone app in eclipse, and it works fine. I created the .jar file, and set it up for distribution, but when i execute it outside of Eclipse, i get a NoClassDefFound error on JCO$Record.

I can see the class in the sapjco.jar file, and i have this file on my classpath. i also have my JCO install folder in my path, so windows can find the .dlls.

I am not sure what is wrong. I check my classpath and path immediately after the exception, and they look fine. i am specifying the classpath with a set statement, and not the -cp extension, if that makes a difference.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

actually, i already do what you suggest. here is my .bat file (please disregard strange newlines in SETs):

@echo off

set OCP=%CLASSPATH%

set OP=%PATH%

set CLASSPATH=c:\JCO\sapjco.jar

set CLASSPATH=%CLASSPATH%;c:\xerces-1_4_4\xerces.jar

set CLASSPATH=%CLASSPATH%;c:\java\MSJDBC\lib\mssqlserver.jar

set CLASSPATH=%CLASSPATH%;c:\com\siemens\SMMSAPInterface.jar

set CLASSPATH=%CLASSPATH%;c:\java\j2sdk1.4.2\jre\lib\rt.jar;

set PATH=%PATH%;c:\jco\;

java -verbose:class -cp %CLASSPATH% -jar c:\com\siemens\SMMSAPInterface.jar

set CLASSPATH=%OCP%

set PATH=%OP%

the CLASSPATH% variable and PATH variable are correct when i look at them (before the final 2 sets), but jvm sill cannot fin sapjco.jar in c:\jco

Former Member
0 Kudos

Could you try to open the sapjco.jar file in winzip and see if the JCO$Record.class is present ?

And also, try using another variablename for the classpath variable. When you supply it directly to the java process it shouldn't read the OS classpath (this shouldn't matter, but you never know)

Former Member
0 Kudos

Yes, JCO$Record is there, and in the the correct package/directory.

I changed the variable name, and turned echo on, and the command line for the "java" command has c:\JCO\sapjco.jar as the first entry after -cp, and this is where the .jar is.

This is just strange. I am not an expert, especially on packages and .jars, but i think this should be working.

what is strange is that it works INSIDE exclipse, but not outside, and they use the same .jar file.

i appreciate all of your help

Former Member
0 Kudos

I still do not know what is going on, becuase i don't understand the whole .jar thing i guess, but...

I changed from .jarring my classes to just creating the appropriate directory structure. this is only MY classes, not sapjco.jar

now it seems to work. i dont know why when MY classes are .jarred, they cannot find sapjco, and when they are not .jarred, and are using the same classpath on the java command line, they find sapjco.jar just fine.

anyways, thanks for the suggestions. i will just run my classes un.jarred

Former Member
0 Kudos

Hi David,

what do you mean with set statement, setting an environment variable? You can of course set an env. variable for classpath(s), but you still have to use the -cp %YOURENV% option to tell the JVM about that.

Hope that helps.

Regards

Stefan