We help IT Professionals succeed at work.

How to make run.bat connect with the jar file on the Start Menu of WinXp

spicymud asked
Last Modified: 2008-01-09
I have written a file "new.java" and changed it into "new.jar";
I also wrote a bat file "run.bat" which content is as follows:
echo off
java -jar new.jar

In the same dir,when I double click the run.bat,the new.jar wil start,the effect of the jar file is that  a Dos command window is displayed.

I use a  software to make "new.jar","run.bat" and another file "help.doc" into a setup software.And you  can use the setup software to install the three files(new.jar,run.bat,help.doc) in some directory.
In the Start Menu of Windows Xp,there are three menus which are linked to these three files.

when I click the menu which is linked to the file of "help.doc",I can soon see the "help.doc" which is installed in one directory.However,when I click the menu which is linked to the file of "run.bat",I can not see the Dos Command Window.The “new.jar" file seems not to run.

so how can I make the menu in the Start Menu of Xp to link to the "run.bat" file correctly so that I can start the "new.jar" file  and see the Dos Command Window?

Thanks in advance.

Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)
You should not need the run.bat :
a proper installation of JAVA (JRE) on Windows sets a Registry link from  .jar to   javaw,
so you can just click a .jar file.

If this is not the case you might install that:

For MSWindows2000:
- Windows Explorer -> Tools -> FileTypes;
Scroll down till you find JAR and select it, then press the Advanced button.
This should pop up a list of Actions, and you'll probably just have one 'open'. Select 'open' and press the 'edit' button on the right. You'll then get (another) dialog showing the action name and the application used to perform the action, something like this:
   "C:\Program Files\Java\j2re1.4.1_01\bin\javaw.exe" -jar "%1" %*


echo off
java -jar \YOUR_FILE_HOME\new.jar
Top Expert 2006
This one is on us!
(Get your first solution completely free - no credit card required)
Right! If you want to make a .jar file out of a .java file (one - to - one) you should do:

javac new.java

jar cvmf Manifest.mf new.jar new.class

Manifest.mf should be a text like:

     Manifest-Version: 1.0
     Created-By: 1.4.2_03 (Sun Microsystems Inc.)
     Main-Class: new
                                                              <----------------------- this is an empty line! do not forget to add it.


And one remark:  as classes should have names starting with a Capital letter, your class should be
     New    rather than    new

As a result all files involved should have names  New  in stead of new.

Second remark:  in the above example you add 2 files to the jar: a class file and a manifest.
Every next addition (class files, pictures, sounds ... ) can be added without necessary changes
to the manifest.

The purpose of the manifest is that JAVA (javaw) can find where to start for a "main( )" as the .jar doesn't have
to have the same name.


Start->Settings->Task Bar & Start Menu->Advanced->Add   .....   I think you can add the command

                              javaw -jar new.jar

Don't forget to supply the right PATHs to javaw   and   new.jar  respectively.

Mick BarryJava Developer
Top Expert 2010
This one is on us!
(Get your first solution completely free - no credit card required)
Indeed, if you never installed JAVA on a fresh XP system, you should download
that's the latest release, from
(3rd section on the page).

I think that a split points would be more appropriate, because objects, GrandSchtroumpf and me
effectivily solved any problem the questioner provided.


Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.