Pete Freitag Pete Freitag

Making Jar files Run

java

I recently had to reinstall my OS, and more recently had to use a Java Application called JEdit. JEdit's installer didn't create any shortcuts for me, so I had to run JEdit from the command line by invoking it's jar file with java -jar jEdit.jar. Since I had just installed java, it was not part of my system path yet, so I actually had to run something like this C:\j2sdk1.4.2_02\bin\java -jar jEdit.jar, quite a pain but it got me thinking about somethings that could be done by Sun when I installed the JVM that would have made my life a lot easier.

First they could have given me the option to add C:\j2sdk1.4.2_02\bin\ to my system PATH. What java developer want's to update this every time they install in new JDK, along with the JAVA_HOME environment variable that some java apps need (like Ant)?

The second issue: why don't jar files execute when you double click them? This turns out to be a fairly easy workaround for someone who knows what they are doing, you just need to set javaw.exe to execute jar files. That is easy for a software developer, but wouldn't it be easier if the JVM did this for you when it was insatlled? Software developers could just say: download this jar file and double click it to run!

If anyone has contacts at Sun, please feel free to forward my comments to them! I'm not just complaining, I'd like to see Java easier to use and more appealing for desktop apps.


Like this? Follow me ↯

Making Jar files Run was first published on November 14, 2003.

If you like reading about java, jar, or jvm then you might also like:

Comments

can't run .jar iles in linux... can anyone help me about this?tnx
by Arnold on 03/02/2004 at 3:23:49 AM UTC
I am creating a jar file
jar cmf SW1.txt Tset.jar SWTHelloWorld.class SWTHelloWorld.java

by executing this command, the jar files gets generated, but when i double click on the Test.jar, it gives the error,"Could not fine the main Class, program will exit". when i look at the meta-inf/manifest.mf file its ok

Manifest-Version: 1.0
Class-Path: Test1.jar
Created-By: 1.4.2_03 (Sun Microsystems Inc.)
Main-Class: SWTHelloWorld

but it islocate in C:\Documents and Settings\103022270\Local Settings\Temp\Manifest.mf

What could be the problem. please guide me.
I am in urgent need

thanks in advance

Basant
by basant on 04/19/2004 at 2:35:33 AM UTC
From memory, the Sun install puts a copy of java.exe into the Windows directory and hence on the path.

Also, by default, the windows install provides a "Executable Jar" file type so that double clicking on a jar executes it using javaw.exe
by dion gillard on 05/12/2004 at 1:13:57 AM UTC
i have tried to run *.jar (game files) files with jdk1.4 but it always gives an error i.e. ("main class not found");
now HOW COULD I ENCOUNTER THIS PROBLEM, any help will be greatly apperiterited on my mail. thanks. ...
by umer on 05/26/2004 at 1:01:40 AM UTC
I downloaded and installed java 2 runtime environment and that seemed to fix my problem. if you have trouble finding it, Email me and I'll email you the web address. Also after I installed j2re, all .jar file icon turned into microsoft word icons but still ran.
by nomad on 12/17/2004 at 11:20:44 AM UTC
I cant use the .jar files wich software should i use, or what should i do. I tried to associate the file as hillbilly told, but it doesnt work. Can anyone help me? mail me please..thanks
by Frankye on 01/16/2005 at 2:53:29 PM UTC
can you send me a java compiler in my email?
by ming on 07/13/2005 at 3:36:22 AM UTC
hai sir,
i created one package
c:\jdk1.5.0\bin\pack>dir
hello.java
hello.class
after i created 1 manifest file
md meta-inf
cd meta-inf
c:\jdk1.5.0\bin\pack\meta-manifest.mf>
mainfest-version: 1.0
main-class: hello
after i xtract
and then , i run it, failed to load
manifest class, but jar format the file is created.
plz help me,
by RaviChandran on 07/16/2005 at 2:07:56 AM UTC
I am using Linux. Typing 'java -jar mp3player.jar' brings up the player, shows me its playing, everything fine, but no sound! :-s Anybody have a solution to this?
by Sanket Medhi on 09/25/2005 at 6:47:21 AM UTC
can u plz tell me the difference b/w jar & jad files. is there any method to run .sis files on nokia 6610
by sourabh on 03/10/2006 at 10:22:52 PM UTC
i complete my NetBeans 4.1 project and also add jfreereport to library of NetBeans 4.1.all run the project is well.But when i use jar.file in project run in desktop,the project cannot print output,why?
help me...tis so important.thanks
by yong on 04/05/2006 at 3:33:16 AM UTC
sir, my jar files do not work every time i double click them they say "could not find the main class: program will exit"
pls help me !!!
by sailesh on 07/29/2006 at 2:49:17 PM UTC
Jar file should handeled care fully.
1.Main-Class: any
2.must be carrige return
3.must blank space between :& classFile

It good in Java ,but jar file should"handle with care"

warm regards
mirza
by MIRZA on 08/17/2006 at 2:09:52 AM UTC
Hi,
any one can send why we are moving to
GenericServlet to HttpServlet any reason???
So many mems saying tht GenericServlet is Protocol independent tht means Http protocol is also there in GenericServlet na .Then why we want to go to HttpServlet.
and
wht is the difference between GenericServlet and HttpServlet...Send me a mai to:
[email protected]

Thanks in advance
Srikanth.P
by Sree on 09/25/2006 at 12:31:03 AM UTC
i want to know ,how i run .jar file in linux,by just double clicking.
by abhijit on 10/04/2006 at 2:54:17 AM UTC
i want know how to run .jar file in mobiles.....or tell me any websites of .jar....
by Ajay on 12/15/2006 at 4:32:20 AM UTC
I have created a jar file.It is executing at the command prompt well. My system is installed with jdk6.When I double click jar,it executes. After uninstallation of jdk6, jar is not running at doubleclick.
by N.sreenath on 01/01/2007 at 12:22:15 PM UTC
How to make a .jar file/ java exe file from .java file???
by Pijush on 01/08/2007 at 2:23:37 AM UTC
how to make a .Jar file/ Java exe in netbeans 5.0
by Tushar on 02/09/2007 at 2:17:27 AM UTC
Could someone plz speak plain english and post a step by step guide on how to make a .jar file run by double clickin and email me PLZ!!! (to tech jargon)

[email protected]
by someone on 07/18/2007 at 4:04:47 AM UTC
I am unable to handle jar files in net beans please even helpout me to how to handle jar files
by Anonymous on 08/01/2007 at 12:40:00 PM UTC
Exception in thread "AWT-EventQueue-1" java.lang.ExceptionInInitializerError
at sun.awt.shell.Win32ShellFolder2$ComTask.execute(Win32ShellFolder2.jav
a:1214)
at sun.awt.shell.Win32ShellFolder2.getFileSystemPath(Win32ShellFolder2.j
ava:557)
at sun.awt.shell.Win32ShellFolder2.composePathForCsidl(Win32ShellFolder2
.java:211)
at sun.awt.shell.Win32ShellFolder2.<init>(Win32ShellFolder2.java:224)
at sun.awt.shell.Win32ShellFolderManager2.getDesktop(Win32ShellFolderMan
ager2.java:87)
at sun.awt.shell.Win32ShellFolderManager2.get(Win32ShellFolderManager2.j
ava:187)
at sun.awt.shell.ShellFolder.get(ShellFolder.java:218)
at javax.swing.filechooser.FileSystemView.getRoots(FileSystemView.java:3
63)
at javax.swing.plaf.metal.MetalFileChooserUI.updateUseShellFolder(MetalF
ileChooserUI.java:430)
at javax.swing.plaf.metal.MetalFileChooserUI.installComponents(MetalFile
ChooserUI.java:189)
at javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserU
I.java:136)
at javax.swing.plaf.metal.MetalFileChooserUI.installUI(MetalFileChooserU
I.java:124)
at javax.swing.JComponent.setUI(JComponent.java:673)
at javax.swing.JFileChooser.updateUI(JFileChooser.java:1762)
at javax.swing.JFileChooser.setup(JFileChooser.java:360)
at javax.swing.JFileChooser.<init>(JFileChooser.java:333)
at javax.swing.JFileChooser.<init>(JFileChooser.java:286)
at ltry.actionPerformed(ltry.java:56)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:19
95)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: java.security.AccessControlException: access denied (java.lang.Runtim
ePermission shutdownHooks)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:323)
at java.security.AccessController.checkPermission(AccessController.java:
546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.Runtime.addShutdownHook(Runtime.java:190)
at sun.awt.shell.Win32ShellFolder2$ComTaskExecutor.<init>(Win32ShellFold
er2.java:1165)
at sun.awt.shell.Win32ShellFolder2$ComTaskExecutor.<clinit>(Win32ShellFo
lder2.java:1156)
... 42 more
by shiva on 10/29/2007 at 8:44:39 PM UTC
How can i execute the jar files....??
by Rajesh on 01/03/2008 at 6:46:26 AM UTC
I am not able to run a .jar file.

I think there is something wrong with the environment variable.
can anyone tell me what do i have give in the environment variables.
by rocky on 03/11/2008 at 9:54:50 PM UTC
Download jar file opener software free!

Download information:
username: stevebasu
password: 111
download link: http://stevebasu.xtgem.com/Software/Java Jar Opener by steve.mix69.net.zip

install this software & run your java file in double click. 100% working.

for all java visit http://steve.mix69.net
by Steve Basu on 03/11/2008 at 11:30:36 PM UTC
I am unable to handle jar files in net beans please even helpout me to how to handle jar file
by mohit on 03/21/2008 at 12:27:34 AM UTC
Failed to load main-class Manifest attribute from XYZ.jar file
by Rajnish on 04/09/2008 at 11:50:39 PM UTC
Running a JAR by double-clicking it or using a simple command is always more convenient than having to include it in your classpath and running a specific main class. To help you do this, the JAR specification provides a Main-Class attribute for the JAR's manifest file.
by Dhariwals on 05/20/2008 at 6:49:04 PM UTC
hoe to create a icon for jar files in netbeans
by rama raju on 06/20/2008 at 7:31:15 AM UTC
I have created the jar file of my project in netbeans. I have also set the main class even though I get some error. like

C:\>java -jar "The_Law__Ketan__18-6.jar"
Exception in thread "main" java.lang.NoClassDefFoundError: org/jdesktop/layout/G
roupLayout$Group
Caused by: java.lang.ClassNotFoundException: org.jdesktop.layout.GroupLayout$Gro
up
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)


please give me solution
by ketan bhavsar on 06/20/2008 at 11:41:44 PM UTC
can't download internet exp 7 - need for numerous this - says temp,jar file, etc.
by carymchark on 06/22/2008 at 6:36:57 PM UTC
hi all,
i built jar of my project. its working fine in windows but giving error - Null Peer?! Exception in Linux.

Please enlighten me on what's going on and possible workarounds.

thanks in advance!
by Pranav on 10/14/2008 at 7:17:01 AM UTC
i am using Linux then how to see the source jar file very very urgent
by murali on 11/19/2008 at 4:13:55 AM UTC
Dear Sir,

Please help me to execute a jar file for running my java file and how I create a .exe file.
by Shaheen on 02/15/2009 at 10:45:15 PM UTC
shaheen...exe is not happens in java...but yup you can run your java file by executing jar files
by rohan on 03/06/2009 at 11:57:32 PM UTC
I tried loading pc game from net and couldnt run it after loading as it stated that the lang is missing.
by RAJ on 12/05/2009 at 12:31:52 AM UTC
Dear friends, you can notonly Run Jar files, but also sis files on pc.

to know how, enail me on: [email protected]
by vivek dhar on 12/24/2009 at 1:11:54 AM UTC
I HAVE A CHINA MOBILE (BLUETOOTH NKTEL ESERIES) I WANT TO RUN .jar FILES ON IT.
PLZ HELP ME
by Owais on 01/16/2010 at 3:33:50 AM UTC
I've many *.jar applications, but i'm unable to run these on my computer. If anyone knows to run java mobile games on computer, plese help me.
by Ritvik Singh on 01/20/2010 at 10:10:00 PM UTC
I created the jar file and manifest file and they all compiled well without any errors but when double click on the jar file, my pc (vista) ask for which program to use in opening the jar file. plz i need HELP !!!!!
by cyril on 02/10/2010 at 10:57:50 AM UTC
I'm trying to run a Program thing, It Won't work.. I try to open it with like java.exe or whatever. And won't work.. I really need this to work, Thanks.
by Chevy on 03/09/2010 at 8:56:30 PM UTC
i run a jar file by clicking it..tell me how to run..It shows an error that "Failed to load Main-class manifest attribute" .
by vidhya on 03/30/2010 at 12:49:34 AM UTC
Well my jar files works fine on double clicking in windows xp and vista but in my windows 7 it gives the famous error: "could not find main class". It works on some other people's computers who also have windows 7, but it didn't work on a few other windows & computers. I don't know why. Help anyone?
by Rhondel on 04/19/2010 at 6:39:14 PM UTC
I just need to add that it runs from command line just fine but on double click I would get the error.
by Rhondel on 04/19/2010 at 6:41:11 PM UTC
Pls i have some problem with my jar file and i use netbeans IDE, after building the project i tried to open the jar on the dist folder instead i receive error msg could not find the main class program will exit pls what do i do to correct this.pls my e-mail [email protected] for reply
by Michael on 04/20/2010 at 8:58:00 AM UTC
how i run a jar file in windows 7
by vikash on 05/09/2010 at 12:28:20 AM UTC
Go to where the Java folder is located and in the java ver you want to use remember that location...Next open Notepad type in notepad the following:

java.exe -jar %1 %

Tell NOTEPAD to save as - tell it in the save as type All Files(*.*) and in the file name area name it Javawindows.bat
REMEMBER that file location you were told to remember... save it there.
Now goto the folder where you have the jar file you want to run highlight it and right click and choose open with - tell it to open with the bat file you just made... you will have to browse to it click ok. and your ready to double click on any jar file in windows and have it open.
by Mohel Castorena on 05/28/2010 at 2:32:53 AM UTC
hello
My problem are i am create java .jar file by help net-beans foe dist folder but i have double click in these jar file they will open as compress folder. So please give any suggestion how to create java executable file
by Balram on 06/15/2010 at 5:24:05 AM UTC
How can i create setup file or .exe file for blackberry smartphone applications plz send me the reply
by saikiran on 06/21/2010 at 5:19:24 AM UTC
I need bluej projects code. please mail me at my email. thanking you.
by Rajesh Naidu on 06/30/2010 at 12:18:32 AM UTC
sir
i am working on net beans 1.6.7 using category
Mobile application i complete one projects but
when i double click on execute able jar.file it give me error failed to
load-main class manifest attribute.
Sir tell me this project is It complete or not ?.
I think i missing somethings in this project. sir
tell me how to solve this problem.And Also guide me how to make jar file for mobile which can run for mobiles. using with net beans 1.6.7
Actually I have made execute able jar files but i can`t get mobile.jar file
by Sonia Ali on 08/03/2010 at 1:57:58 PM UTC
I have created a jar file. It executes when i execute like java -jar filename.jar but when i try to execute by double click it not executing it shows error message could not find main class c:\...filename.jar program will exit
how can i solve this problem pls send me in [email protected]
by Ashlin on 01/03/2011 at 10:50:39 PM UTC
i have tried to run *.jar (game files) files with jdk1.4 but it always gives an error i.e. ("main class not found"); now HOW COULD I ENCOUNTER THIS PROBLEM, any help will be greatly apperiterited on my mail. thanks. ...
by dahrmendra kumar on 02/12/2011 at 10:35:50 AM UTC
plzz tell me how can i use attractive lookandfeel in J2SE ?? i want to give a look and feel like any media player ... plzz help .. thnxx
by omar on 02/28/2011 at 12:47:32 AM UTC
i can creat a jar file but when i click on it to run then an error box containing the comment: "failed to load mainclass...." something like this u no.
plz hep me..
by sanjeev jajoria on 03/24/2011 at 6:24:41 AM UTC
I can create a .jar file in netbean 6.9 but how it can be a installable file in another computer as we install any stand alone software?

plz help me!!
by Misbah on 06/20/2011 at 8:59:12 AM UTC
I have a jar file which runs in java enabled mobile. but I want to make it .exe file for security. could any help me?
by bangaraiah on 06/25/2011 at 12:12:45 AM UTC
These LCs start every platform in news explicitly currency
combinations, and you should trace those LCs that can be trusted on charts tout de suite
reoccur improve of later reference. Authorized crossovers can be trusted in the chap infrastructure, and prohibited crossovers
cannot be trusted. Over again, verboten crossovers are interpreted near clashing traders who gather into work
old signals such as pivots as an access, again causing losses.
by Bavodosnund on 07/18/2011 at 4:21:35 PM UTC
Creating running jar file>>>>
iam giving here an example
.after u creating jar file by using
jar -cfm name.jar main.class
.
Here name.jar is the name of jar file
.
Main.class is the name of the main class
.
After created u open by right clicking in winrar or other and change the content of
"manifest.mf"
.edit in new line
Main-class:name
.
Here name is the name of main class
.
Then save and try to re open it by double click..
Voila u hav created
by Sabir ashraf on 08/01/2011 at 2:32:53 AM UTC
I decompiled a jar made some chnages and then again recompiled using jar cmf MANIFEST.MF MYNAME.JAR *.CLASS. BUT WHEN I AM TRYING TO RUN THE JAR BY USING JAVA -JAR MYJARNAME.JAR
java -jar QCentral.jar
Exception in thread "main" java.lang.NoClassDefFoundError:
by richa on 09/20/2011 at 5:11:19 AM UTC
hello im having a problem with running the " mysql-connector-java-5.0.8-bin.jar " archive file so what could i do?
by roland khoury on 12/06/2011 at 4:41:07 PM UTC
Unable to read jar files inside a jar file. Was able to read when we put that in the same folder as jar file. What we should give in manifest file/class-path to read jar files inside that jar file
by Jishnu on 12/21/2011 at 9:45:00 AM UTC
I had got an error in my weka jar file installation that denotes that main class manifest is not installed.i'm unable to recover that please send some suggestions and give a suggestion that how to install and set the classpath for the weka jar files.Thanks in advancce.
by kalyani on 01/31/2012 at 1:49:12 AM UTC
I made a form in netbeans 6.9.1 after makin it i converted that form into jar file using clean & built method after creating i double clicked on tht jar file but was nt able to execute i also tried using command prompt but was nt at able to work and yes i also tried converting that file into exe but still it dint worked what i shud do now?
by Kiran on 02/26/2012 at 8:25:41 AM UTC
Hello everyone,

can someone help me, where to get the JAR software for X201 nokia mobile, word, and PDF file are not accessable, what i wan is to change it JAR, but i need the software to installation.

Thank you,by advance,
by Ahmad Mia on 04/12/2012 at 1:45:58 AM UTC
Hey, I still got an error even through this process..
C:\Program Files (x86)\JavaEmulator.com\KEmulator>java -cp KEmulator.jar emulato
r.Emulator
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Program Files (x86
)\JavaEmulator.com\KEmulator\swt-win32-3346.dll: Can't load IA 32-bit .dll on a
AMD 64-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(Unknown Source)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at emulator.k.a(Unknown Source)
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
at emulator.ui.swt.aK.<init>(Unknown Source)
at emulator.Emulator.main(Unknown Source)
I tried to run KEmulator in manny ways, but still can't spot the error.. Please e-mail me asap... :)
by Atox Gatal on 12/27/2012 at 7:29:36 AM UTC