Solved

Java executable .jar - spaces in directory path

Posted on 2001-06-23
5
2,154 Views
Last Modified: 2013-11-23

I have an executable .jar file (in Windows), that is a Swing application. When I start it by double-clicking on it, it will start only if the path it is in has no spaces in the directory path. (For example, c:\program files\myapp will not work since "program files" contains a space.

On the other hand, it will always start if it started from the command line (ie. java -jar My.jar). I know the double-click invokes javaw (instead of just java), but I don't understand why one works and the other doesn't.

I do access "user.dir" and append a subdirectory to it in my code. Could this be part of the issue? However, why does the command line invocation work?

Any thoughts?

Thanks,
Joel
0
Comment
Question by:joeltt
5 Comments
 
LVL 3

Accepted Solution

by:
superschlonz earned 60 total points
ID: 6222134
I think that is a registry problem. I don't know where it is in the registry,
perhaps you find it when you search for javaw.

if you find a string like 'javaw -jar %1' change it to 'javaw -jar "%1"'

Oh, I found something in
HKEY_CLASSES_ROOT/jarfile/Shell/Open/command
0
 
LVL 92

Expert Comment

by:objects
ID: 6222145
Sounds like you need to edit the Windows action associated with a jar file.
I think the way to do this depends on your version of Windoze but I'll go thru the Win2k procedure and you should get the idea.
Select 'Folder Options' from the Explorers Tool menu.
In the dialog pick the 'FileTypes' tab, which will present a list of file extensions/types. 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\JavaSoft\JRE\1.3.0_01\bin\javaw.exe -jar %1

Windows replaces the %1 with the filename of the (jar) file that u d-clicked, and if it contains spaces then the command line looks like this:

javaw.exe -jar c:\Program Files\XYZ

So it think the name of the jar is c:\Program.

To fix this simply edit the application used to perform action by putting quotes around the %1:

C:\Program Files\JavaSoft\JRE\1.3.0_01\bin\javaw.exe -jar "%1"

That should do it :)
Let me know if you have any problems.
0
 
LVL 1

Expert Comment

by:sumeetsh
ID: 6224048
hi
i have an application which uses executable jar file,and the path for the application is C:\Program Files\myBill
and I start it by double-clicking on it and it works.
I am using JDK1.2.1 and jre 1.2
its on Windows NT.
What i have done is i have add JRE to the systems PATH.





0
 
LVL 3

Author Comment

by:joeltt
ID: 6236072
You got the answer first. Thanks,J
0
 
LVL 92

Expert Comment

by:objects
ID: 6236424
Beaten my 3 minutes :-)
Good to hear you solved your problem.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now