Solved

Java executable .jar - spaces in directory path

Posted on 2001-06-23
5
2,173 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
fibonacci ten numbers 4 45
How to execute a Python program and gather return output in Java 2 40
jsp insert to database example 2 46
running on tomcat not jboss eap 7.0 3 18
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

861 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