mruff
asked on
Problem running *.jar file java.lang.NoClassDefFoundError
hello,
when I try to run my pgm with: D:\Data\mruff\spectroCVS\P rojects\B2 BServer>D: \Applicati ons\Progra mming\Java \jdk
1.3\bin\java.exe -jar B2BServer.jar
I get:
Exception in thread "main" java.lang.NoClassDefFoundE rror: com/wbk/B2BServerAppl
ication
I have the following manifest file:
Manifest-Version: 1.0
Created-By: 1.3.0 (Sun Microsystems Inc.)
Main-Class: com.wbk.B2BServerApplicati on
Class-Path: . D:\Applications\Programmin g\Java\jdk 1.3\jre\li b\rt.jar D:\Data\mruff\spectroCVS\P rojects\B2 BServer\li b D:\Data\mruff\spectroCVS\P rojects\B2 BServer\li b\jdom.jar D:\Data\mruff\spectroCVS\P rojects\B2 BServer\li b\xerces.j ar D:\Data\mruff\spectroCVS\P rojects\B2 BServer\li b\mysql.ja r D:\Data\mruff\spectroCVS\P rojects\B2 BServer\li b\FTPProto col.jar D:\Data\mruff\spectroCVS\P rojects\B2 BServer\li b\OROMatch er.jar D:\Data\mruff\spectroCVS\P rojects\B2 BServer
I put the files in the following directory structure:
META-INF/manifest.mf
com/wbk/myclasses
then I jar all. I can see the Manifest.mf file is in the jar file at the correct loacation.
I have no idea what is wrong here
P.S. in the manifest file I also tried with slahes as delimiters (Main-Class: com/wbk/B2BServerApplicati on) did not work either
when I try to run my pgm with: D:\Data\mruff\spectroCVS\P
1.3\bin\java.exe -jar B2BServer.jar
I get:
Exception in thread "main" java.lang.NoClassDefFoundE
ication
I have the following manifest file:
Manifest-Version: 1.0
Created-By: 1.3.0 (Sun Microsystems Inc.)
Main-Class: com.wbk.B2BServerApplicati
Class-Path: . D:\Applications\Programmin
I put the files in the following directory structure:
META-INF/manifest.mf
com/wbk/myclasses
then I jar all. I can see the Manifest.mf file is in the jar file at the correct loacation.
I have no idea what is wrong here
P.S. in the manifest file I also tried with slahes as delimiters (Main-Class: com/wbk/B2BServerApplicati
What is the output of jar -tf B2BServer.jar?
do you have the declaration:
package com.wbk;
at the top of your B2BServerApplication.java file?
package com.wbk;
at the top of your B2BServerApplication.java file?
if you have jar your classes correctly, then i can say that it is the class path for that jar is not setted correctly.
For example, B2BServer.jar resides in D:\jar
then you need to set your D:\jar in the classpath. Otherwise it cannot find the class and will give you NoClassDefFoundError
For example, B2BServer.jar resides in D:\jar
then you need to set your D:\jar in the classpath. Otherwise it cannot find the class and will give you NoClassDefFoundError
> For example, B2BServer.jar resides in D:\jar
> then you need to set your D:\jar in the classpath.
That will NOT pick up B2BServer.jar.
jar's must be explicitly included in your classpath, or simply placed in your ext directory where they will get automatically included.
Sounds like you haven't included your files in your jar correctly.
> then you need to set your D:\jar in the classpath.
That will NOT pick up B2BServer.jar.
jar's must be explicitly included in your classpath, or simply placed in your ext directory where they will get automatically included.
Sounds like you haven't included your files in your jar correctly.
To Objects:
i supposed you are referring to weblogic server when you mention "ext directory".
It seems to be a bug, whereby it doesn't automatically include the jars.
i supposed you are referring to weblogic server when you mention "ext directory".
It seems to be a bug, whereby it doesn't automatically include the jars.
What's weblogic got 2 do with it??
(Since 1.2) Any jar file placed into the ext folder located inside your jre installation will be included in your classpath.
But I don't think the problem is with the command line, or classpath. The problem appears to be with the construction of the jar file.
(Since 1.2) Any jar file placed into the ext folder located inside your jre installation will be included in your classpath.
But I don't think the problem is with the command line, or classpath. The problem appears to be with the construction of the jar file.
ASKER
hi,
to stimpyjcat :
I build the the jar file with the following ant-script
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="dist" name="B2BServer">
<!-- set global properties for this build -->
<property name="src" value="src"/>
<property name="build" value="build"/>
<property name="dist" value="dist"/>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>
<target depends="init" name="compile">
<!-- Compile the java code from ${src} into ${build} -->
<javac destdir="${build}" srcdir="${src}">
<classpath>
<pathelement path="${classpath}"/>
<fileset dir="./lib">
<include name="**/*.jar"/>
<include name="**/*.class"/>
</fileset>
<pathelement location="./build"/>
</classpath>
</javac>
</target>
<target depends="compile" name="dist">
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>
<mkdir dir="${build}/META-INF"/>
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar basedir="${build}" jarfile="${dist}/lib/B2BSe rver-${DST AMP}.jar" manifest="./manifest/MANIF EST.MF"/>
<copy file="${dist}/lib/B2BServe r-${DSTAMP }.jar" tofile="./B2BServer.jar"/>
<!-- Delete the ${build} and ${dist} directory trees -->
</target>
<target depends="dist" name="clean">
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>
to black: yes, I can run the application without any problem, if the *.class files are not packed in a *.jar file
to stimpyjcat :
I build the the jar file with the following ant-script
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="dist" name="B2BServer">
<!-- set global properties for this build -->
<property name="src" value="src"/>
<property name="build" value="build"/>
<property name="dist" value="dist"/>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>
<target depends="init" name="compile">
<!-- Compile the java code from ${src} into ${build} -->
<javac destdir="${build}" srcdir="${src}">
<classpath>
<pathelement path="${classpath}"/>
<fileset dir="./lib">
<include name="**/*.jar"/>
<include name="**/*.class"/>
</fileset>
<pathelement location="./build"/>
</classpath>
</javac>
</target>
<target depends="compile" name="dist">
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>
<mkdir dir="${build}/META-INF"/>
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar basedir="${build}" jarfile="${dist}/lib/B2BSe
<copy file="${dist}/lib/B2BServe
<!-- Delete the ${build} and ${dist} directory trees -->
</target>
<target depends="dist" name="clean">
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>
to black: yes, I can run the application without any problem, if the *.class files are not packed in a *.jar file
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that was the answer, now it works
a tool named JavaJar
can compress and decompress war, ear and jar....
may download from http://www.qwerks.com/download/4114/JavaJar.zip
the tool is very good tool.
but the homepage(www.pivotonic.com) of JavaJar cannot be accessed.
it is funny.
can compress and decompress war, ear and jar....
may download from http://www.qwerks.com/download/4114/JavaJar.zip
the tool is very good tool.
but the homepage(www.pivotonic.com) of JavaJar cannot be accessed.
it is funny.