Solved

Java executable .jar - spaces in directory path

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Python Assistance 7 80
nextBoolean(double p) for Random class 3 40
jsp insert to database example 2 24
Java: The Public Class Main 4 16
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 …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

772 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