954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

running a jar file

Hello again,

I've been around some threads here, some interesting, some piqued my interest. Like, forgive my ignorance, but how does one run a jar file. What special is required to run such a file? All I know is winrar a jar file and you get all these coded .class files, which has no meaning with a code, from my point of view. Please someone explain I can run a jar file without the actual source code.

Ronica

ronicasingh
Newbie Poster
16 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
 
jasimp
Senior Poster
3,623 posts since Aug 2007
Reputation Points: 533
Solved Threads: 53
 

if the jar you have is an executable jar, just doubling clicking on it should make it run, However if that doesn't work the at the command line type:

java -jar filename.jar

If that too doesn't work (which means the manifest file was not properly included with the jar), you will have to give specify the Main class of your jar. For example if the main class is Alpha inside the package "daniweb" which in turn is inside the package "com", you will have to type:

java -cp filename.jar com.daniweb.Alpha


Also here is the chapter from The Java Tutorials covering the basics and uses of Jar files.

stephen84s
Nearly a Posting Virtuoso
1,443 posts since Jul 2007
Reputation Points: 668
Solved Threads: 154
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You