The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


issues installing a java application on various flavors of windows

Posted by Matt Gerrans on December 12, 2001 at 5:40 PM

Here's what I'd do:

I'd write a little Windows program in C/C++ that reads an INI file that looks something like this:

java=C:\Program Files\MyCompany\MyJRE\bin\javaw.exe
java Params=-Xbootclasspath/p:"C:\Program Files\MyCompany\MyApp\boot.jar" -jar
Java Target="C:\Program Files\MyCompany\MyApp\MyApp.jar"

When you run the program it would appropriately assemble all the above, add any parameters that it was given and ShellExecute() the results.

Note, this would not be console app, it would be a Windows app; that is, it would have a WinMain() entry point, not a main(). This program would probablly be smaller than 30K bytes and would work all all Windows platforms. It would take a few hours to write and would probably never need to be updated again. It would not pop up any DOS box. I would make it so the program gets it own location, with GetModuleFilename() and looks for an INI file in the same place with the same base name. Then I would put the link to it on the desktop.

If you wanted to get fancy, it could even look around for the JVM if the specified one isn't found (or at least show a useful message).

Another option is to do all this with a little JScipr, which can be run on all windows platforms with wscript. In that case, all the above details would be in the JScript, the link would contain wscript script.js and the Jscript would do the same trick of tacking its parameters on to the java call befure calling on it. You might want to make a nice custom icon for the link (in the exe suggestion above, you can add your nice icon to the exe itself).

> i have a java application that i'm packaging up with installshield to deliver to customers that may install on windows nt/95/98/2000. i'm having trouble getting the following combinations to work:

> scenario 1:

> under all versions of windows i can create a desktop shortcut that has the following target:

> "C:\Program Files\MyCompany\MyJRE\bin\javaw.exe" -Xbootclasspath/p:boot.jar - jar MyApp.jar

> and then i can double-click the shortcut and launch my application. no problem. however...

> when i try to drag and drop my application specific files onto the icon and have it launch and open the file, this only works under windows 2000. other windows versions appear to lose the parameters and try to execute the following command:

> "C:\Program Files\MyCompany\MyJRE\bin\javaw.exe" MyFile

> which, of course, fails because it's not a class or jar file -- it's a data file!

> any suggestions on how to set up the windows nt/95/98 shortcuts without using a BAT file? (i have no desire to have a dos command console window/icon show up every time a user runs my java application.)

> scenario 2:

> i'm setting up a windows registry entry to associate my file
> extensions with my application so a double-click of a data file will automatically launch my java application and open the file. the registry entry looks like this:

> "C:\Program Files\MyCompany\MyJRE\bin\javaw.exe" -Xbootclasspath/p:"C:\Program Files\MyCompany\MyApp\boot.jar" -jar "C:\Program Files\MyCompany\MyApp\MyApp.jar"

> this time everything works great under windows 95/98/200. however...

> this time windows nt has a limit on the command length in the registry so it truncates the entry and i get an error when double-clicking in NT.

> again, any suggestions on how to set up the windows nt registry
> without using a BAT file?

> thanks in advance for any suggestions!


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us