• Post Reply Bookmark Topic Watch Topic
  • New Topic

issue while running a jar file in unix, but the same works fine in Windows  RSS feed

 
deepak buddineni
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created jar file for my project called MyJar.jar .

1)When running in windows:
(C:\Users\Desktop\MyJar.jar has all the dependent jars in C:\Users\Desktop\testlib\)

So i run the program using the command :
C:\Users\Desktop> java -cp C:\Users\Desktop\testlib\*;C:\Users\Desktop\testlib\MyJar.jar com.abc.MyMain

The program runs absolutely fine!!!

2)When running in Unix:
/tmp/test/lib/MyJar.jar has all the dependent jars in /tmp/test/lib/*

So i run the program using the command :
/tmp/test > java -cp /tmp/test/lib/*;/tmp/test/MyJar.jar com.abc.MyMain

I get this error:

$ java -cp /tmp/test/lib/*;/tmp/test/MyJar.jar com.abc.MyMain
Exception in thread "main" java.lang.NoClassDefFoundError: /tmp/test/lib/commons-logging-1/1/1/jar
Caused by: java.lang.ClassNotFoundException: .tmp.test.lib.commons-logging-1.1.1.jar
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: /tmp/test/lib/commons-logging-1.1.1.jar. Program will exit.
-ksh: /tmp/test/MyJar.jar: cannot execute [Permission denied]


 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The path separator in Linux is colon ( : ), not semicolon ( ; ).

The semicolon separates one command from another, much like it separates one statement from another in Java. That's why you got
at the end.

You first tried to execute java with only one of your jar files, and then after that you said, "next, execute the other jar file."
 
deepak buddineni
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes sir.It works now.
Thanks for the quick reply.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!