• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

java executable

hi experts,
please I need  detailed steps for this..I don't know what I'm doing..
I have an application and I want to run it on another computer (windows OS)and make it an .exe file so you just double click and it works..please don't give me links to look at unless they envolve exactly what Im asking for because Ive browsed over 20 web sites without understanding what I need to do. Im using JBuilder..
some sites say I need to make a jar file which I did but Im not sure is correct or not..
other sites say I need an installer and I also need to download runtime environment(which I couldn't find anyway) and include it on the CD I will create for users without it on their PCs.. Im lost with no idea what to do


speady answers would be greatly appreciated..thanks for the help

bye
0
Samooramad
Asked:
Samooramad
  • 7
  • 6
  • 3
1 Solution
 
sudhakar_koundinyaCommented:
creating a executable jar is better option

A new and cool feature of Java2 is the ability to create executable jar files. A jar file is simply a file containing a collection of java files (typically, java .class files, but any other kind of file could be included as well). To make a jar file executable, you need to specify where the "main" Class is in the jar file, so the "java" command knows what main() method to invoke to get the software going. The procedure is quite simple, and this document provides step-by-step instructions. For more details on jar files, consult http://java.sun.com/docs/books/tutorial/jar/.

   1. First, make sure you have installed Java 1.2 or above. This facility is not available in previous versions of Java.

   2. Next, create your working java system. In general, you will want to put it into a package. For this example, I created a trivial HelloWorld application that prints out "Hello World" plus the first command line argument, and placed it into the package "psae". Therefore, the HelloWorld files (HelloWorld.class, HelloWorld.java) were located in the directory psae. I tested the system to make sure it worked before going on to the next step.

   3. In the directory in which the psae is located, created a file called "mainClass". This file contains a single line specifying where the main Class is to be found in the jar file. Note that I use the package specification. Here is the single line:

Main-Class: psae.HelloWorld

      Note: make sure you type a carriage return after this line; some windows systems need it and will report a "Failed to load Main-Class manifest attribute" error.

   4. Next, I create a jar file called psae.jar using the "jar" command in Java2. I use the "m" command line argument to specify the manifest file mainClass, which adds information to the jar file on where the main class will be found. Here is the jar command:

bertha:~ > jar cmf mainClass psae.jar psae

   5. Just for fun, and to check what's happened, I print the table of contents for the jar file I just created. Here's the command and its result:

bertha:~ > jar tf psae.jar
META-INF/
META-INF/MANIFEST.MF
psae/
psae/HelloWorld.java
psae/HelloWorld.class

   6. Having successfully created the jar file, I can now invoke java2 on it with the command line argument:

bertha:~ > java -jar psae.jar Philip
Hello World Philip
0
 
SamooramadAuthor Commented:
well I have JDK 1.4 which I downloaded with JBuilder...will that work for me?
0
 
SamooramadAuthor Commented:
>>To make a jar file executable, you need to specify where the "main" Class is in the jar file,
I'm not sure exactly what you mean..Al I know is I have a jar file and a manifest that says version 1.0 and in the second line it has my main class name..Is that what you mean?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
SamooramadAuthor Commented:
I guess what you are saying is I should create the manifest myself then to make sure there is a carrige return right?
0
 
Tommy BraasCommented:
Hi Samooramad,

You can download InstallAnyhere Now! for free from www.installanywhere.com. It will allow you to, not only create an executable, but also create an installer for your program.

Cheers!

\tt
0
 
sudhakar_koundinyaCommented:
>> I guess what you are saying is I should create the manifest myself then to make sure there is a carrige return right?

True
0
 
sudhakar_koundinyaCommented:
>>I'm not sure exactly what you mean..Al I know is I have a jar file and a manifest that says version 1.0

Create your own Mainifest File and Place line something like following
Main-Class: psae.HelloWorld

where HelloWorld is a main class and psae package
0
 
sudhakar_koundinyaCommented:
>> well I have JDK 1.4 which I downloaded with JBuilder...will that work for me?

Yes it will
0
 
SamooramadAuthor Commented:
can I create a manifest file from an ordinary text file? using notepad or something?
0
 
sudhakar_koundinyaCommented:
>> can I create a manifest file from an ordinary text file? using notepad or something?

Yes you can. It is just a text file
0
 
SamooramadAuthor Commented:
ok I will try it
0
 
SamooramadAuthor Commented:
hasnt worked yet :(
0
 
Tommy BraasCommented:
sudhakar_koundinya,

You really shouldn't copy and paste from the internet, and then try to take credit for it! Provide a link instead: http://csdl.ics.hawaii.edu/~johnson/613f99/modules/04/jar-files.html , be honest.
0
 
sudhakar_koundinyaCommented:
>>You really shouldn't copy and paste from the internet, and then try to take credit for it! Provide a link instead:

I knoow that friend. Generally along with the matter I copied, I do post the link also. I forget that this time.

Generally  I do this because of two reasons.

1. Instead of opening two pages (Question thread and reference url), I do think that it will be easy to get the information with in same page

2. Some times in the older threads of EE, if I try to open the referenced links , I do get page not found errors. Like that I do missed maximum information (for the questions I answered and I asked)- Some times Very good Stuff. That is the reason, although content is duplicated, I do post  the content from URL.

Just because of not posting the link, this makes you to to think that I am not honest :((

Regards
Sudhakar
0
 
SamooramadAuthor Commented:
orangehead911 thanks for the link..the program was very helpfull

thanks
0
 
Tommy BraasCommented:
My pleasure! =-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now