wood burning stoves*
The moose likes Java in General and the fly likes Packaging a Swing application as exe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Packaging a Swing application as exe" Watch "Packaging a Swing application as exe" New topic
Author

Packaging a Swing application as exe

Santosh Raveendran
Ranch Hand

Joined: Jun 29, 2008
Posts: 83
Hi Team

i have developed a small swing application using netbean5.5.1 IDE and it working fine , i have used the package option under build to package the application, i found that my GUI jar executes only if its inside the project folder ,
i want to package my entire application as a executable file and want to install it in my machne , can any one advice on this

SCJP 1.4,SCWCD5, SCBCD5
Thanks, Santhosh
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
not a 'Swing' problem, better off putting your question to a Netbeans forum
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42374
    
  64
By "executable file", do you mean double-clickable? If so, then jar files can do that. If the application relies on other libraries, then you'll need to adapt the jar file manifest accordingly; see http://faq.javaranch.com/java/JarFiles for more detail.


Ping & DNS - my free Android networking tools app
Santosh Raveendran
Ranch Hand

Joined: Jun 29, 2008
Posts: 83
Hi Ulf,

Thanks for the response ,let me explain my requirement currently if i check my project directory which i got as i

explained above , i have a directory created by the name dist and it contains a directory lib and my GUI jar

Processor.jar , when i am viewing the MANIFEST.MF inside META-INF of my Processor.jar it has referenced the

springlayout.jar available in the lib folder , i want to create the entire thing either as a jar or exe file which can be

installed in a windows machine, please advice.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42374
    
  64
If the Class-Path entry in the manifest file simply refers to "springlayout.jar" (without any directory), then you can simply put both jar files in the same directory and they will work. Is it of vital importance that only a single file is distributed? You could distribute a ZIP file that extracts to a directory containing all the required files; that's a common method of distribution.

You could also re-package all required class files into a single jar file for distribution.
Santosh Raveendran
Ranch Hand

Joined: Jun 29, 2008
Posts: 83
Hi Ulf,


is there any way we can install this jar so that it will come under programs in a windows machine
eric aro
Greenhorn

Joined: Dec 04, 2009
Posts: 15
for small programs, using maven, (or by hand) you can package all your classes, and all dependencies classes into a single jar.

then you use launch4j with the option "embed jar", and you'll get an independent exe, that works right out of the box.

This solution is nice, but not scalable for big programs (with megas of dependencies )

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19726
    
  20

Michael Dunn wrote:not a 'Swing' problem, better off putting your question to a Netbeans forum

I half agree. This is not a Swing problem, but I think Java in General is a better problem since creating EXE or JAR files is not IDE specific.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42374
    
  64
is there any way we can install this jar so that it will come under programs in a windows machine

That's just a directory like any other; what difficulty are you facing putting the file there?
 
Consider Paul's rocket mass heater.
 
subject: Packaging a Swing application as exe