Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 04-04-2004, 11:29 PM   #1
Member (13 bit)
 
Floppyman's Avatar
 
Join Date: Mar 1999
Posts: 6,791
Self-Installers

Hi all,

I've written a program in JAVA that consists of many classes. I'd like to somehow create installer that installs all the files and let's you launch the program. Right now it always runs through the compiler (JBuilder) and I'd like to get away from that. TIA.
Floppyman is offline   Reply With Quote
Old 04-05-2004, 08:11 AM   #2
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
I use this one, it's free, and easy to use.

And I suggest you put all of your classes in one JAR file, and include the JRE in your package or tell the user how to get it.
aym is offline   Reply With Quote
Old 04-10-2004, 12:13 PM   #3
Member (13 bit)
 
Floppyman's Avatar
 
Join Date: Mar 1999
Posts: 6,791
Hi,

Thanks for the link. I downloaded Nsis install software. Is there a place that shows you how to use the scripting language that is involved with it? Also how would you install a JAVA program? You said put the files into a JAR file, but is there anything else I would have to do? Thanks again.
Floppyman is offline   Reply With Quote
Old 04-10-2004, 01:55 PM   #4
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
Hi Floppyman,

You don't need to know the scripting language to create an installer, just download NSIS 2.0 and HM NIS Edit, both are available in the download page, install them both, then start the HM NIS Edit, select "Create new script using wizard", and follow the instructions, then compile the generated and script, and the installer .exe should be generated.

As for installing a Java program, create a JAR file out of the class files, configure the installer to copy this file to the installation directory, and create a shortcut for it in the start menu.

If the JRE is installed, the program will start when the user clicks on that link.

Finally, how to create a JAR file, compile your program, and copy all .class files to a new directory, inside that directory, create another directory called "META-INF", in this directory, create a text file called "MANIFEST.MF", open it in a text editor, type the following:
Code:
Manifest-Version: 1.0
Main-Class: ClassName
ClassName is the name of the class that contains the main method.

Now in the command line, cd to the directory that contains the .class files, and enter the command:
Code:
jar cMf program.jar *
And your JAR file should be there.

NSIS docs:
http://nsis.sourceforge.net/Docs/

More info on JAR files:
http://java.sun.com/docs/books/tutorial/jar/

Good luck.
aym is offline   Reply With Quote
Old 04-10-2004, 08:39 PM   #5
Member (13 bit)
 
Floppyman's Avatar
 
Join Date: Mar 1999
Posts: 6,791
Hi,

Thanks again for your help. I tried the command to create the .jar file but it did not work. I'm working on a windows 2000 box (unfortunately). So, I created a .jar file through Jbuilder, however I still can not launch it. When I try to open it with javaw.exe it says the main class cannot be found. I can open it through the commandline like this though:

java -jar myprogram.jar

and it will launch right up. Any ideas? Thanks again.
Floppyman is offline   Reply With Quote
Old 04-11-2004, 06:52 AM   #6
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
Hi,

I forgot to say that you need to add two blank lines to the end of the MANIFEST.MF file.

Does it help?
aym is offline   Reply With Quote
Old 04-11-2004, 08:36 AM   #7
Member (13 bit)
 
Floppyman's Avatar
 
Join Date: Mar 1999
Posts: 6,791
Hi,

Well when I tried the jar command from the command line it says the command was recognized (even if I try from within the JAVA folder). That's why could never create the JAR file. I was able to create one with JBuilder, but when I doubleclick on it, it doesn' t open it. What application should be used to open it? I can launch the jar file fine from the command line and it works? This is all in windows. Thanks again.
Floppyman is offline   Reply With Quote
Old 04-11-2004, 08:43 AM   #8
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
Do you have the Java SDK installed? jar.exe is in the bin directory.

Set your Parh environment variable to contain this directory:
Control Panel > System > Advanced > Environment Variables, edit the Path variable and add c:\path\to\jdk\bin to it.
aym is offline   Reply With Quote
Old 04-11-2004, 12:08 PM   #9
Member (13 bit)
 
Floppyman's Avatar
 
Join Date: Mar 1999
Posts: 6,791
Hi,

Thanks again for the reply. Does the JDK have to be installed as well? I thought I only needed the JRE. I willl give this a try though and then try the jar command again. Thanks again.

Last edited by Floppyman; 04-11-2004 at 12:11 PM.
Floppyman is offline   Reply With Quote
Old 04-11-2004, 12:11 PM   #10
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
Hi,

You only need the JDK when creating the JAR file, the JRE can run JAR files just fine, but it can't create them.

So include the JRE with your installer, not the JDK.

As for the Path variable, no the JDK doesn't change it.
aym is offline   Reply With Quote
Old 04-11-2004, 07:33 PM   #11
Member (13 bit)
 
Floppyman's Avatar
 
Join Date: Mar 1999
Posts: 6,791
Hi,

Thanks again for the reply I think I got everything working. I ended up creating the JAR files in JBuilder. I changed some settings on my file extensions and now I can double click on the JAR files an open them. I guess you need to have type "Executable JAR File" in your file types list, otherwise it doesn't work. I couldn't do this before, but after installing the JDK it started working. Strange. I wonder if that had anything to do with it.

Is there anyway of turning a JAR into a .exe executable? Also how could I create custom icons for my program and have the install script use them? Thanks again.
Floppyman is offline   Reply With Quote
Old 04-12-2004, 01:50 PM   #12
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
Hi,

There are some compilers that compile Java into native code, but I don't think there is any complete one, the compilers I tried didn't support all of the Java library.

However, there are programs that create a .exe file out of the compiled .class files, when the .exe is executed, it starts the JRE and the main .class file.

I suggest you stick to JAR files, as long as the JRE is installed, the program will run fine, to make sure that your program runs even if javaw.exe isn't associated with .jar files, create a shortcut to "javaw.exe path\to\.jar instead of a shortcut to the .jar file itself.

As for changing the shortcut's icon, look in the created script for the command:
CreateShortCut "path" "name"
Add "" and then the icon path to its end:
CreateShortCut "path" "name" "" "path\to\icon.ico"

For more info, read CreateShortCut documentation.

HTH
aym is offline   Reply With Quote
Old 04-12-2004, 03:24 PM   #13
Member (13 bit)
 
Floppyman's Avatar
 
Join Date: Mar 1999
Posts: 6,791
Thanks again. Is there any software that would allow you to create custom icons? TIA.
Floppyman is offline   Reply With Quote
Old 04-13-2004, 06:27 AM   #14
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
Sorry, I don't do graphic design, I think you need to ask in the General Software forum or something
aym is offline   Reply With Quote
Old 04-24-2004, 07:31 PM   #15
Member (13 bit)
 
Floppyman's Avatar
 
Join Date: Mar 1999
Posts: 6,791
Hi again,

I have one more question for you. What option would I have to add into the installer script so that a certain part of the program is not checked by the default to be installed (in the installer)? Thanks again.
Floppyman is offline   Reply With Quote
Old 04-25-2004, 06:09 AM   #16
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
Hi,

Create a section for this part in the wizard, after that the script is generated, search for something like:
Code:
Section "SectionName" SEC#
And change it to:
Code:
Section /o "SectionName" SEC#
And don't forget to check "Allow user to select the components to install" in the wizard.

Good luck
aym is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:51 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2