November 14, 2003
Making Jar files Run
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.
Related Entries
20 people found this page useful, what do you think?
Trackback Address: 24/A7A3587E580F1CCAFA84FACC39EDBB66
What I did was to create a batch file, jax.bat, saying: @java -jar %1 and I put this in my java/bin folder. I then associate .jar-files with jax.bat.
can't run .jar iles in linux... can anyone help me about this?tnx
i am not able to schedule the jar command on linux crontab please help....
for those on windows change the jar file type association to
"C:\Program Files\Java\j2re1.4.2_04\bin\javaw.exe" -jar "%1" %*
Change the directory to the location of the actual javaw file and be sure to include the "-jar"
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
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
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. ...
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. ...
start it with "javaw.exe -jar bla.jar" instead of "javaw.exe bla.jar" that solves the problem
DEAR ONE,
I AM JANET RICHARD FROM LIBERIA WEST AFRICA PRESENTLY RESIDENT IN COTE D'IVOIRE/IVORY COAST. DUE TO THE POLITICAL WAR THAT HAS CLAIMED THE LIVES OF MY PARENTS THAT CAUSED ME TO LEAVE THE COUNTRY. THEREFORE,UPON THIS BACK GROUND I AM KINDLY ASKING YOU TO HELP ME GET OUT OFF AFRICA INCLUDING THE FUND OF($7.5MILLION USD)WHICH MY FATHER DEPOSITED IN A BANK HERE IN COTE D'IVOIRE FOR SAFETY BEFORE HIS DEATH.
I AM SOLICITING FOR A GOOD AND LONG TIME RELATIONSHIP WITH YOU IN HELPING ME TO TRANSFER THIS FUND INTO YOUR ACCOUNT OR COUNTRY FOR INVESTMENT. AS YOU MAY KNOW I DON'T HAVE IDE OF INVESTMENT OR BUSINESS MATTERS. THANKS FOR YOUR UNDERSTANDING AND CO-OPERATIONS IN THIS MAIL.
I AM HOPING TO HEAR FROM YOU SOON AS POSSIBLE. RESPECTFULLY ONE. JANET RICHARD.
long time since post...but still I never had much problem with path. It's easy enough to set anyway.
Exectuting jar files with double click: when java jdk installs it associates the jar file with java so that double clicking will run it... but some programs (like zip utilities) change the association. So tell those programs not to open .jar files
JANET or whatever your name is, can you stop with this kind of stupid lines, we aren't interresting, get lost!!!!
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.
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
<h1>Please check the pages dedicated to- Tons of interesdting stuff!!! </h1>
can you send me a java compiler in my email?
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,
how to create executable for java as vb executable files so that just by clicking we can connect to the output.
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?
Just another example of how Sun has screwed up the spread of Java. If Sun wants to compete with Microsoft, at least make creating .jar files with the NetBeans IDE work out of the box. Having to fiddle with a manifest file is ridiculous.
I am unable to bundle my java application in Jar file. It always shows the error "main-class def. not found". How can I create an self executable java Application which executes on double clicking?
As far as I'm concerned smart people do stupid things becuase they think everyone else is as smart as them. If that makes sense to you. Anyways I had the same problem many of you have opening and bundling java applications. It's kind of a tricky thing. Here's a link straight from the bastards who make it so hard to distribute thier own software http://java.sun.com/docs/books/tutorial/deployment/jar/manifestindex.html that will tell you a lot more than you want about the manifest files but thats the key to geting your application to run on double clicking or shit running at all as distributed software. An easier way is just to download netbeans 5.0 rc1 and it will do most of it for you all you have to do is include any libraries you want to use hope that's helpful. I have a website with a downloadable zip java .jar file at this website let me know if it is working becuase it works when i download it on my machine www.freewebs.com/verbalassasiin/index.htm
Thank you, it's worked fine :-\ start it with "javaw.exe -jar bla.jar" instead of "javaw.exe bla.jar" that solves the problem
can u plz tell me the difference b/w jar & jad files. is there any method to run .sis files on nokia 6610
can someone help me out. need a program that runs TAG files
not sure if this is what you need
Run .jar as .exe http://bact.blogspot.com/2005/07/run-jar-as-exe.html
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
C:\>cd j2sdk1.4\bin
C:\j2sdk1.4\bin>java -jar jEdit.jar Exception in thread "main" java.util.zip.ZipException: The system cannot find th e file specified at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.<init>(ZipFile.java:112) at java.util.jar.JarFile.<init>(JarFile.java:117) at java.util.jar.JarFile.<init>(JarFile.java:55)
"Hello sir plz help me for creating jar file frm java file .i typed given command but on reply got these errors."
help sir whts the problem.
PLZ help me. I got jad files that needs to be converted to jar files. I cant find a program for it. Please help me my e-mail is tclou@webail.co.za.
hi, i have nokia application installer installed on my computer and jar files are associated with it so when i try to open a jar file they open in nokia.... can someone please help
I wise man told me that the reason the double clicking doesn't work correctly is becuase it is only meant to work with GUI applications. He is correct if you even look at the sample applications that come with your jdk you will see that any GUI application will run on double clicking but none GUI related applications still execute but so quickly that you can't see them. One solution is to turn your jar's into executable files there are a few out there here's one I found http://mpowers.net/executor/ then you have to add an if statement something like System.out.print("Press 1 then enter to quit"); int number = scanner.nextInt(); if (number == 1) System.exit(1); }// end main at the end of your main method. That way the program won't exit until you ask the user to exit it. For help with your java homework assignments visit us at www.freewebs.com/codepalz
how do you open a java game onto the pc, to play it and install it?
Hi there !I just figured out that you can use Launch4j to create exe file to execute jar file.This tool saved me alot!
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 !!!
Hi all, I have created .jar file. It is working through command line(java -jar example.jar) but it doesn't execute while I doube click. The error is listed below,
Error : "could not find the main class".
Thanks in advance!
Regards, Abdul Majid
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
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: srikanth_nlr_p@yahoo.com
Thanks in advance Srikanth.P
i want to know ,how i run .jar file in linux,by just double clicking.
snket plz.. sen me dat jar file i will solve...shaikhsuhaibiqbal@yahoo.com
i want know how to run .jar file in mobiles.....or tell me any websites of .jar....
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.
How to make a .jar file/ java exe file from .java file???
how to make a .Jar file/ Java exe in netbeans 5.0
to make a .jar, use Java BlueJ. Project menu/Create jar file...
If something is missing the main class, remember that to create an exe file, you will need to have a class which contains a main method with the following signature: "public static void main()"
Greatings
check this http://java.sun.com/docs/books/tutorial/deployment/jar/index.html
Sorry, this is the good one:
If something is missing the main class, remember that to create an exe file, you will need to have a class which contains a main method with the following signature: "public static void main(String[] arg)"
Check this as well:
http://bact.blogspot.com/2005/07/run-jar-as-exe.html
As Anonymous has written, don't forget "System.exit(1);" at the end.
hi,i am new to java... now i want to add a jar file.... what should i do...
Pls tell me, How to run jar game in my pc. Tell me exact Environment Variables I need to set. mail me to cnrraj@yahoo.co.in
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)
evezhang1@yahoo.com
http://www.javaworld.com/javaworld/javatips/jw-javatip127.html
read this you will get your answer
I am unable to handle jar files in net beans please even helpout me to how to handle jar files
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
How can i execute the jar files....??
hi.. plz help me, i am not able to play mobile themes in my nokia N 91 8GB phone. it says that phone does not support .sis files so i need to play . jar files. But how cal i install or play themes in my mobile with .jar files..
Plz reply at mailin_rohit@yahoo.co.in
Please help me how can i run mobile java application (jar file) on my PC. i have downloaded Java software but i couldn't run it. Visit my moble java games site http://gameszone.wen.ru Mobile software site http://j2meSoft.wen9.net Mobile All downloads http://www.stevebasu.tk & http://steveonline.mix69.net
How can I run jar files on my black berry mobile. Reply me on aminves@yahoo.com
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.
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
I am unable to handle jar files in net beans please even helpout me to how to handle jar file
I couldn't agree more. Obstacles like these has kept me from learning Java for years - I can never even get started with the environment working, much less enjoy whatever benefits are to be had, because the Sun documentation (not to mention the third-party developer docs that come with other app distros) are not comprehensive. Look - a person who already knows what they're doing isn;t going to read the readme file anyway. So please at least make the install readme understandable to a novice. It just makes sense. Arrgh. Thank you for your eloquence.
Failed to load main-class Manifest attribute from XYZ.jar file
Failed to load main-class Manifest attribute from XYZ.jar file Reply on rajnish2494@gmail.com