Solved

How to run a jar files class in UNIX?

Posted on 2009-04-01
10
1,433 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
Comment Utility
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
Comment Utility
try

java javaTest
0
 
LVL 20

Expert Comment

by:Venabili
Comment Utility
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
 
LVL 26

Expert Comment

by:ksivananth
Comment Utility
java -cp JavaFolder/TestJava.JAR javaTest.Test

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

Author Comment

by:matrixrasta
Comment Utility
Hi ksivananth
what do you mean by complete path?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 24

Expert Comment

by:sciuriware
Comment Utility
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
Comment Utility
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
Comment Utility
>>what do you mean by complete path?

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

Expert Comment

by:sciuriware
Comment Utility
.... as in my second example ......
0
 
LVL 24

Expert Comment

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


;JOOP!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now