Sunteți pe pagina 1din 2

8/3/2016 HowtocreateaJarfileinNetbeansStackOverflow

signup login tour help

Dismiss

AnnouncingStackOverflowDocumentation
WestartedwithQ&A.Technicaldocumentationisnext,andweneedyourhelp.
Whetheryou'reabeginneroranexperienceddeveloper,youcancontribute.

Signupandstarthelping LearnmoreaboutDocumentation

HowtocreateaJarfileinNetbeans

WellIhavemysourcecodethatihavedoneusingtheIDEnetbeans.NowIwantedtomovethisjavaapplicationtoawebapplication.ForthatI
needtocreateajarfilefrommysourcecode,sothatIcouldinvokeitinmajspfile.Ihavenotbeenabletofindanyoptioninnetbeansorany
otherwaytocreatea.jarfileofthissourcecode.Couldsomeonetellmehowtodothat.

Thanks

netbeans jar

askedMar13'12at10:01
user1227433
215 3 6 9

3Answers

CreateaJavaarchive(.jar)fileusingNetBeansasfollows:

1.RightclickontheProjectname
2.SelectProperties
3.ClickPackaging
4.CheckBuildJARafterCompiling
5.CheckCompressJARFile
6.ClickOKtoacceptchanges
7.RightclickonaProjectname
8.SelectBuildorCleanandBuild

CleanandBuildwillfirstdeletebuildartifacts(suchas .class files),whereasBuildwillretain


anyexisting .class files,creatingnewversionsnecessary.Toelucidate,imagineaprojectwith
twoclasses,AandB.

Whenbuiltthefirsttime,theIDEcreates A.class and B.class .Nowyoudelete B.java but


don'tclearout B.class .ExecutingBuildshouldleave B.class inthebuilddirectory,andbundle
itintotheJAR.SelectingCleanandBuildwilldelete B.class .Since B.java wasdeleted,no
longerwill B.class bebundled.

TheJARfileisbuilt.ToviewitinsideNetBeans:

1.ClicktheFilestab
2.ExpandProjectname>>dist

Ensurefilesaren'tbeingexcludedwhenbuildingtheJARfile.

editedMay3at16:31 answeredDec26'13at14:09
DaveJarvis CBC_NS
15.8k 24 103 201 776 2 11 24

Pleasedorightclickontheprojectandgotoproperties.ThengotoBuildandPackaging.You
canseetheJARfilelocationthatisproducedbydefualtsettingofnetbeaninthedistdirectory.

answeredOct31'13at9:24
user2342262
112 1 3

http://stackoverflow.com/questions/9681876/howtocreateajarfileinnetbeans 1/2
8/3/2016 HowtocreateaJarfileinNetbeansStackOverflow
4 heybudthepathdisplays'dist/JavaApplication1.jar'butIcannotfindthatinmydistfolderSaumilSoni
Dec25'13at11:54

IntheNetbeansIDEyoucan'tseeallthefilesinthe'Projects'(onlythosetheNetbeansprogrammersthink
youneedfordeveloping),howeverifyoubringupthe'Files'tabyoushouldbeabletoseealltheproject
files.JohnPaulMay6'15at13:54

IalsotriedtomakeanexecutablejarfilethatIcouldrunwiththefollowingcommand:

javajar<jarfile>

AftersomesearchingIfoundthefollowinglink:

PackagingandDeployingDesktopJavaApplications

Isettheproject'smainclass:

1.Rightclicktheproject'snodeandchooseProperties
2.SelecttheRunpanelandenterthemainclassintheMainClassfield
3.ClickOKtoclosetheProjectPropertiesdialogbox
4.Cleanandbuildproject

TheninthefodlerdistthenewlycreatedjarshouldbeexecutablewiththecommandI
mentionedabove.

editedDec10'15at4:20 answeredAug10'15at9:06
JoshCrozier Raimundo
95.4k 25 139 139 308 2 13

I'mnotseeingadistfolder.AnystepsorsettingsI'mmissing? ClarkHenry Sep5'15at4:50

GotothewhereyourNetBeansprojectislocatedinthefilesystem.Forthefolderdistbethereyoumust
buildorcleanandbuildtheproject.RaimundoSep6'15at9:02

protectedbyCommunity Aug10'15at9:06
Thankyouforyourinterestinthisquestion.Becauseithasattractedlowqualityorspamanswersthathadtoberemoved,postingananswernowrequires10reputation
onthissite(theassociationbonusdoesnotcount).

Wouldyouliketoansweroneoftheseunansweredquestions instead?

http://stackoverflow.com/questions/9681876/howtocreateajarfileinnetbeans 2/2

S-ar putea să vă placă și