• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running a java program in unix

 
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]


 
Campbell Ritchie
Sheriff
Posts: 51366
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you putting code into /tmp rather than your home directories?
 
Campbell Ritchie
Sheriff
Posts: 51366
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Closing as a duplicate of this discussion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic