Solved

How to run a jar files class in UNIX?

Posted on 2009-04-01
10
1,484 Views
Last Modified: 2012-05-06
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
Comment
Question by:matrixrasta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +2
10 Comments
 

Author Comment

by:matrixrasta
ID: 24039029
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 24039047
try

java javaTest
0
 
LVL 20

Expert Comment

by:Venabili
ID: 24039052
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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 26

Expert Comment

by:ksivananth
ID: 24039489
java -cp JavaFolder/TestJava.JAR javaTest.Test

assuming JavaFolder/TestJava.JAR is the complete path!
0
 

Author Comment

by:matrixrasta
ID: 24039954
Hi ksivananth
what do you mean by complete path?
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 24040063
The above examples are contradicory:


at the prompt, type:

> java -jar MyProgram.jar

as simplest example.

;JOOP!
0
 
LVL 24

Accepted Solution

by:
sciuriware earned 250 total points
ID: 24040073
So, if the jar-file is in /tmp  ::


>  java -jar /tmp/MyProgram.jar

;JOOP!
0
 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 250 total points
ID: 24040135
>>what do you mean by complete path?

the path of the jar from the root!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 24040145
.... as in my second example ......
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 24040159
.... but my first example works fine if the .jar is in the current directory.


;JOOP!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to configure empty element in XML Document parser? 15 59
Java array 10 89
Pass multiple values or string arrays in java as a parameter 3 73
junit initializtion error 2 22
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded‚Ķ
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question