I have an java application which contains run.bat file as below:
rem set path=D:/Applns/jdk1.5/bin
set classpath=.;lib/derby.jar;lib/mail.jar;lib/activation.jar;lib/commons-codec-1.3.jar
start javaw net.sf.veettukaaran.appclient.ApplicationController
when I run this run.bat
in windows, the application works fine. But I want to run this in ubuntu 12.04
. So I tried to convert the run.bat
to run.sh
as below:
# /bin/sh
java -classpath './lib/derby.jar:lib/mail.jar:lib/activation.jar:lib/commons-codec-1.3.jar' net/sf/veettukaaran/appclient/ApplicationController
when I run this script by ./run.sh
it gives me class not found exception as below:
Caused by: java.lang.ClassNotFoundException: net.sf.veettukaaran.appclient.ApplicationController
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: net/sf/veettukaaran/appclient/ApplicationControll. Program will exit.
Can somebody please point out what I am doing wrong ? I have checked the path of the specified jar files in classpath
and class file and it is correct. some other idea what might be wrong ?
Thanks
Replace the following
java -classpath './lib/derby.jar:lib/mail.jar:lib/activation.jar:lib/commons-codec-1.3.jar' net/sf/veettukaaran/appclient/ApplicationController
with
java -classpath '.:./lib/derby.jar:lib/mail.jar:lib/activation.jar:lib/commons-codec-1.3.jar' net.sf.veettukaaran.appclient.ApplicationController
Notice that I have just added current directory .
to your classpath
and corrected the class package name in front of the class by replacing /
with .
well I could run run.sh file finally. It looks like below:
# /bin/sh
java -cp ':./lib/derby.jar:./lib/mail.jar:./lib/activation.jar:./lib/commons-codec-1.3.jar' net.sf.veettukaaran.appclient.ApplicationController
After that I run this command: " dos2unix run.sh
" and then I run ./run.sh
. and this way application gets executed.
I thnak you all for your responses..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.