How to run a jar files class in UNIX?

Dear Experts

How can I call a class thats in my JAR File (JavaFolder/TestJava.JAR) in UNIX

The Java package is called javaTest and the class is called Test.java

My question is can any one give me a syntax example on how one run the java class?

Thanks
matrixrastaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
sciuriwareConnect With a Mentor Commented:
So, if the jar-file is in /tmp  ::


>  java -jar /tmp/MyProgram.jar

;JOOP!
0
 
matrixrastaAuthor Commented:
I know its based on this:      
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
0
 
omarfaridCommented:
try

java javaTest
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
VenabiliCommented:
The same way you do in in Windows. The only difference is that the classpath separator is : and not ; if you want to set a classpath
java javaTest.Test
0
 
ksivananthCommented:
java -cp JavaFolder/TestJava.JAR javaTest.Test

assuming JavaFolder/TestJava.JAR is the complete path!
0
 
matrixrastaAuthor Commented:
Hi ksivananth
what do you mean by complete path?
0
 
sciuriwareCommented:
The above examples are contradicory:


at the prompt, type:

> java -jar MyProgram.jar

as simplest example.

;JOOP!
0
 
ksivananthConnect With a Mentor Commented:
>>what do you mean by complete path?

the path of the jar from the root!
0
 
sciuriwareCommented:
.... as in my second example ......
0
 
sciuriwareCommented:
.... but my first example works fine if the .jar is in the current directory.


;JOOP!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.