Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1513
  • Last Modified:

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
0
matrixrasta
Asked:
matrixrasta
  • 4
  • 2
  • 2
  • +2
2 Solutions
 
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
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
sciuriwareCommented:
So, if the jar-file is in /tmp  ::


>  java -jar /tmp/MyProgram.jar

;JOOP!
0
 
ksivananthCommented:
>>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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now