How to convert from filefrom .Java to .Jar

How to convert from filefrom .Java to .Jar

Page 1 of 1

3 Replies - 24506 Views - Last Post: 21 June 2009 - 06:44 PM Rate Topic: -----

#1 A.Sa3d  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 31-March 09

How to convert from filefrom .Java to .Jar

Post icon  Posted 21 June 2009 - 01:10 AM

Hi

please gays how can i convert from file .java to .Jar
Is This A Good Question/Topic? 0
  • +

Replies To: How to convert from filefrom .Java to .Jar

#2 Gasper  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 66
  • Joined: 29-May 09

Re: How to convert from filefrom .Java to .Jar

Posted 21 June 2009 - 04:13 AM

You don't actually convert it. jar = Java archive, just like zip or rar. To store files in jar use command line:
jar cvf JarName.jar FirstClass.class SecondClass.class

try jar --help for more info.
+ you should add manifest info file into jar to point main class and to add some informations
Was This Post Helpful? 0
  • +
  • -

#3 DaneAU  Icon User is offline

  • Great::Southern::Land
  • member icon

Reputation: 286
  • View blog
  • Posts: 1,619
  • Joined: 15-May 08

Re: How to convert from filefrom .Java to .Jar

Posted 21 June 2009 - 07:06 AM

I think you need a manifest file also so you when you do java -jar myJar.jar it knows which class has the main method :/

When you use the above command jar cvf JarName.jar FirstClass.class SecondClass.class a default manifest is created in the .jar - it would look something like this if you opened it

Manifest-Version: 1.0
Created-By: 1.6.0_04 (Sun Microsystems Inc.)


You need to make it point to the class containing the public static void main(String[] args) method. To do this you would need the MANIFEST.MF file too look like this

Manifest-Version: 1.0
Created-By: 1.6.0_04 (Sun Microsystems Inc.)
Main-Class: Interface


Thats assuming your main class is called Interface.

You can open .jar files in most compression programs. If you are unsure what they are google 7-zip, i know it opens .jars

Good luck

PS : I cannot remember off the top of my head how to set the main class via command prompt

This post has been edited by bbq: 21 June 2009 - 07:29 AM

Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,908
  • Joined: 06-March 08

Re: How to convert from filefrom .Java to .Jar

Posted 21 June 2009 - 06:44 PM

http://java.sun.com/...deployment/jar/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1