Hi
please gays how can i convert from file .java to .Jar
How to convert from filefrom .Java to .JarHow to convert from filefrom .Java to .Jar
Page 1 of 1
3 Replies - 17690 Views - Last Post: 21 June 2009 - 06:44 PM
Replies To: How to convert from filefrom .Java to .Jar
#2
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
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
#3
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
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
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
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
#4
Re: How to convert from filefrom .Java to .Jar
Posted 21 June 2009 - 06:44 PM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|