At the moment, when someone else wants to run a Java program I wrote (Windows) I make a batch file that sets the PATH to Java and sets the CLASSPATH to include my jar and a couple other jars from other programs that are typically installed on their machines. The problem is that they often have different versions of Java and of the other programs they need and are pretty much unable to edit a batch file.
I was thinking I could write another batch file that uses regedit to find Java and these other programs and then creates the batch file to run my program. I am hoping there is a better solution. Anyone who may have been in the same situation have any suggestions?
Put your application on a website and let people access it via Java Web Start. Your configuration takes care of saying what version of Java you need and the download process takes care of making sure the client machine has it.
You don't need to set the CLASSPATH system variable. As a matter of fact, it's recommended not to do so. Your jar will automatically be included if you execute it. You can include other jars your program depends on in the manifest file of your executable jar. You can package these jars together with your program if they are not too big, so they will always be in a fixed location relative to your program.
Joined: Oct 10, 2011
Thanks for the replies. Java Web Start is not an option. I'm not sure that I understand the comments about CLASSPATH.
Let's say the person that is going to run the program has version 1.5 of application X. My application imports classes from application X. What I am doing at the moment is:
set CLASSPATH=%CLASSPATH%;C:\Program Files\X\v1.5\lib\x.jar
in a batch file that eventually runs my program.
But it may be that they are using v1.4 or v1.6 and they may have the 32bit version in Program Files (x86) rather than the 64 bit version. They might even have done a custom install and dropped the thing in Program Files\MyX. I don't know how I would know that when I create the manifest.
Also, the plan is to have a desktop icon. So I thought I would have to run java -jar my.jar. So doesn't Java need to be in PATH?
I guess that just sending them the application and leaving it up to them to make it work isn't a possibility either?
If that's the case, then I wouldn't pay any attention to anything installed on their machine. I would distribute everything I needed -- Java runtime, the application, the right versions of the supporting jars, the whole thing. I wouldn't rely on anything which might happen to be on their systems.
And of course the easiest way to do that is still to use Web Start. But if you don't have the infrastructure to support that (i.e. a web server) then I would recommend a Java installer which puts everything into the right place.
Joined: Oct 10, 2011
Round 1 was sending a template batch file and having them edit it so that the paths were appropriate to their machine. That was pretty much a bust. I don't have a web server and there are some business rules on the other end that make web start problematic.
I more or less know how to find applications in the registry. So round 2 was going to be building the batch file on the fly. Then I got into all the Windows stuff, which made me think I'd need to do this as vbscript if I wanted a desktop icon. Which got me to worrying about actually putting my stuff in Program Files, as I'm not quite sure how to tell Windows 7 to elevate a process so that I can copy files there. I'm work mostly on Linux machines, so this whole transparent install under Windows seems a bit daunting.
I looked at the Nullsoft scriptable install system. It doesn't seem to have been touched in a long time, will it handle Windows 7 user account control?
I also was looking at 'Advanced Installer' (http://www.advancedinstaller.com). Has anyone use their product? I think if I do include absolutely everything, then their installer might work, it was hard to tell from the tutorials.
Is there another product I should be looking at (that is not too expensive)? It seems like there are a lot of them, but not a lot of discussion of their quality.
So yeah, it sounds like an installer is the way to go. No point learning Windows security internals when you can acquire a product which already knows about them.
However I don't have any recommendations, or even any experience with those things. And I rarely see them discussed here on the Ranch, so I won't even nag you to search the forums for answers. But good luck with your search.
A cool way if you use an IDE like Eclipse is packaging the libraries inside the jar you distribute and compile it as a runnable jar.
Thene the command to launch is as simple as java -jar fileJAR.jar params
Sure it increases the jar size but you don't need to include any external classpath on system's variables.
That's how I compile them for my apps.
Sorry I cannot help with windows installers and all that
Joined: Oct 10, 2011
What is complicating my life is that not everything I will be running is Java. My program uses a tool called RJava that starts R. It assumes that R is in the PATH. The installers that I have found so far, don't seem to be set up to let me run something that finds the path to R and then writes the batch file to call my program with R added to the PATH. I could put R in my install tree, but I'm not sure the installers pass back where they actually put things. Any suggestions on handling the PATH problem?
Note: R's desktop icon includes the full path to R. I am pretty sure I can find it in the registry (though R can be installed either globally or in a local directory, which complicates things a little).