• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Running a java program in unix

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]


 
Marshal
Posts: 80639
472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you putting code into /tmp rather than your home directories?
 
Campbell Ritchie
Marshal
Posts: 80639
472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Closing as a duplicate of this discussion.
 
reply
    Bookmark Topic Watch Topic
  • New Topic