Solved

How to run a jar files class in UNIX?

Posted on 2009-04-01
10
1,473 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySQL  on Tomcat 8 70
eclipse apache tomcat admin console 52 122
Error in @AspectJ Based AOP with Spring 2 18
ejb example issues 3 28
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

828 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