Improve this answer. Anders Anders Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.
Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Helping communities build their own LTE networks. Podcast Making Agile work for data science. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Related Hot Network Questions. That is, it is a call to the Java Virtual Machine java. Java applications are not much different from regular Windows applications, except for that they are not. Checking for a Java Runtime Environment.
If the system doesn't have a JRE installed, then it won't be able to launch java applications. The JRE from Sun Microsystems is freely available to download and can be freely distributed as well, so that is another strategy for ensuring that java is installed.
We could just download the JRE installer from Sun Microsystems, and then provide that as part of the installation. How do you run a program from the installer? However, Exec runs the command and continues immediately; it is a non-blocking call. What we would like is for the JRE to install and then continue on with the rest of the installation. For that reason, use ExecWait. Just make sure that the JRE installer is first extracted with the File command to either a temp directory or the install directory first and then execute that.
Environment Variables. How does a java application find all the classes that it uses? Setting the working directory. In almost all operating systems, a call can be made to an executable file from anywhere.
Suppose you have MyApplication. To run MyApplication. Like this:. This kind of example works in Unix as well of course, the directories wouldn't be starting with "C:". What is different about these two program calls.
The working directory of each application is different. The working directory is the directory from which the application is launched. As you have seen, it doesn't necessarily have to be the directory where the program is installed. Go to your start menu, and under programs, find a shortcut. Right-click on this shortcut and now in the new window, look at the text box labelled "Start In:".
That is the working directory of that application. How do we make sure that the working directory in our shortcuts are where we want them to be?
Look back to the first example where we created start menu shortcuts. Notice that we have set an Outpath for copying files. If you would like to change the working directory of a shortcut, then simply change the OutPath to what you would like, create the shortcut, and then, if you want, change the OutPath back. Creating Start Menu shortcuts for running java. Typically, the target of a shortcut in the start menu is a simple. If you look at any shortcut's properties in your start menu, you may notice that the "Target" field is in quotations.
For simple targets, Windows likes to put quotes around the entire call. What happens when you have a target that takes in some kind of command line parameter? For example, you have a. The call to the function would have to be something like:. When you have some target such as this, Windows doesn't like to put quotes around the program call.
Why does this matter to a java application? Since to run a java program, one has to type "javaw MyApplication," it can be seen as a call to an. Thus, we cannot have quotes around the target in our shortcut. The following then, will not work:. What we need to do is create a shortcut for executing 'javaw. This is done by simply adding another "quotation" part after the executable part, like this:. To run a java class from a jar file, you can type something like this:.
The extra "quotation" section with our classname is all you need to run your java application. Of course, you'll need your icon file to be installed to your installed directory, so don't forget to do that. A Java Example. Here is the. More specifically, it does the following:. Look at the script below for doing the above tasks. It may look a little intimidating, but there is a lot of whitespace and comments to make it easier to understand:.
If you have NSIS installed, then compile the script and files and see what happens. If you would like to just get the installer. SectionEnd Please help. Please don't double post. I have stated this on the other post you made. I don't know why but it should work. This basic script works:. The following was missing: SetShellVarContext all :.
0コメント