How Do I Jar A Java File.

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 22, 2009, 02:37 AM
430658 members and 297804 Topics
Latest Member: vjvj
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming  |  How Do I Jar A Java File.
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: How Do I Jar A Java File.  (Read 156 views)
technobayo (m)
How Do I Jar A Java File.
« on: October 27, 2009, 01:53 PM »

Please, how do i jar a java file in jdk 1.6. Specifically, i've often had problems accessing a database program i wrote after jarring the application. Maybe, that's where the problem lies. hola folks
Ghenghis (m)
Re: How Do I Jar A Java File.
« #1 on: October 27, 2009, 08:21 PM »

I'm going to assume you compiled your classes with something like

javac -cp foo.jar -d outputĀ  *.java
where foo.jar is an external library you used

so that the full class directory structure is created in directory output

then for jar :

jar cvf myApp.jar output\*

If the jar is to be run in windows like an executable jar, you might need to create your own manifest file ,
Seun (m)
Re: How Do I Jar A Java File.
« #2 on: October 27, 2009, 10:01 PM »

How about a WAR file?
Ghenghis (m)
Re: How Do I Jar A Java File.
« #3 on: October 28, 2009, 10:27 AM »

A war file can also be created using the same technique however the directory structure must follow that of a standard WAR archive.
i.e WEB-INF, WEB-INF/classes, WEB-INF/lib etc.

Also remember to use myApp.war instead of myApp.jar

logica
Re: How Do I Jar A Java File.
« #4 on: October 28, 2009, 11:00 AM »

Or you go the dummy way and use an IDE (such as Eclipse). In Eclipse you can create any archive (JAR, WAR, EAR) by exporting the project. Eclipse figures out which type of archive you are trying to create by the type of project (Java Standard Application - JAR,  Java Web Application - WAR, Java Enterprise Application - EAR).
candylips (m)
Re: How Do I Jar A Java File.
« #5 on: October 30, 2009, 12:07 PM »

or better still automate the whole thing from the command line using Ant or Ivy or Maven. Java has got a lot easier with all these open source tools
Ghenghis (m)
Re: How Do I Jar A Java File.
« #6 on: October 30, 2009, 08:26 PM »

Quote from: candylips on October 30, 2009, 12:07 PM
or better still automate the whole thing from the command line using Ant or Ivy or Maven. Java has got a lot easier with all these open source tools

I love ANT (hate maven) , when the build starts getting complex , with jars scattered all over then you should start thinking ANT (or Maven  Cry)

but for simple builds with a few jars, nothing beats javac and jar. Knowing both commands has saved me many times at, say, a client's site with only the JDK as a weapon.

I think most people's problem is a lack of understanding of java CLASSPATH, once the JCP gets rid of it finally, maybe we'll have fewer jar or compile issues  Undecided

Cheers
candylips (m)
Re: How Do I Jar A Java File.
« #7 on: October 31, 2009, 11:34 AM »

Ghenghis i normaly refer to Maven as Ant Version 2. I hated it initially too but now i can't do without it.

Once u get a handle over it u will see how powerful and easy it is
javarules (m)
Re: How Do I Jar A Java File.
« #8 on: November 03, 2009, 07:49 AM »

Quote from: logica on October 28, 2009, 11:00 AM
Or you go the dummy way and use an IDE (such as Eclipse). In Eclipse you can create any archive (JAR, WAR, EAR) by exporting the project. Eclipse figures out which type of archive you are trying to create by the type of project (Java Standard Application - JAR,  Java Web Application - WAR, Java Enterprise Application - EAR).
I don't agree with you on this. Using an IDE (especially for Java Developement) is no longer the dummy way, in fact its the smart way. Ask @javalove lol
 Please Help !its Urgent  Need Programming Ebooks?  Getting The Services Of An Advertising Agency  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 


Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.