Error running java -jar command
Posted
by dmantamp
on Stack Overflow
See other posts from Stack Overflow
or by dmantamp
Published on 2010-05-16T10:28:44Z
Indexed on
2010/05/16
10:40 UTC
Read the original article
Hit count: 647
Hi all, I created a jar file using the following ANT script
<manifestclasspath property="jar.classpath" jarfile="${bin.dir}/${jar.app.name}" maxparentlevels="0">
<classpath refid="main.class.path" />
</manifestclasspath>
<target name="jar">
<mkdir dir="${build.dir}/lib/isp"/>
<mkdir dir="${build.dir}/lib/jasper"/>
<copy todir="${build.dir}/lib/jasper">
<fileset dir="${lib.jasper.dir}">
<include name="**/*.jar" />
</fileset>
</copy>
<copy todir="${build.dir}/lib/isp">
<fileset dir="${lib.isp.dir}">
<include name="**/*.jar" />
</fileset>
</copy>
<jar jarfile="${bin.dir}/${jar.app.name}"
index="true"
basedir="${classes.dir}" excludes="lib/mytest.jar "
>
<manifest>
<attribute name="Main-Class" value="${main.class}" />
<attribute name="Class-Path" value="${jar.classpath}" />
</manifest>
</jar>
</target>
The resulting jar file has the following MANIFEST.MF entry.
Main-Class: dm.jb.Main
Class-Path: lib/isp/OfficeLnFs_2.2.jar lib/isp/RXTXcomm.jar lib/isp/ba
rbecue-1.0.6d.jar lib/isp/commons-logging-1.1.jar lib/isp/forms-1.0.5
.jar lib/isp/gnujaxp.jar lib/isp/helpUI.jar lib/isp/inspInstaller.jar
lib/isp/itext-2.0.1.jar lib/isp/itext-2.0.2.jar lib/isp/jcalendar-1.
3.2.jar lib/isp/jcl.jar lib/isp/jcommon-1.0.10.jar lib/isp/jcommon-1.
0.9.jar lib/isp/jdnc-0_7-all.jar lib/isp/jdnc-runner.jar lib/isp/jdom
.jar lib/isp/jfreechart-1.0.6.jar lib/isp/jlfgr-1_0.jar lib/isp/junit
.jar lib/isp/log4j-1.2.9.jar lib/isp/looks-1.3.2.jar lib/isp/msbase.j
ar lib/isp/mssqlserver.jar lib/isp/msutil.jar lib/isp/mysql-connector
When I try to run the command
java -jar mytest.jar
, it fails and throws error saying dm.jb.Main not found. But I could run the class by specifying the classpath java -classpath dm.jb.Main
Please help me DM
© Stack Overflow or respective owner