Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Executable JAR

  Asked By: Craig    Date: Mar 30    Category: Java    Views: 556
  

Maybe someone know how to make an executable JAR?
i've made a JAR before and there always notification that i must choose the main
class?
although i was choosing the main class in METAINF.MF file?

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Corinne Rogers     Answered On: Mar 30

java has no executables if the .jar was execuatable, it would no longer
be a .jar.

to make a runable jar,

create a jar  called MyJar

Have a class  inside called MyJar

Inside that have a main().

 
Answer #2    Answered By: Agatha Miller     Answered On: Mar 30

Jar is not an executable, but can act as one. Define in the manifest.mf
file the following lines:
Manifest-Version: 1.0
Created-By: 1.4.0 (Sun Microsystems Inc.)
Main-Class: your.main.class.with.package

There is also some other tools to create an executable  for java.
Take a look at http://www.excelsior-usa.com/jetlatest.html

 
Answer #3    Answered By: Sonya Flores     Answered On: Mar 30

while associating jar  files with javaw don't forget to give -jar option e.g.

"C:\Program Files\Java\j2re1.4.0_01\bin\javaw.exe" -jar "%1"

 
Answer #4    Answered By: Eric Foster     Answered On: Mar 30

it still isnt executable  as such is it.

the contents of the jar  is still the same, its just got a file
association on a local computer. it wont have that association on other
computers will it. so nothing has changed.

i suspect the OP is new to java for this type of question.

 
Answer #5    Answered By: Oliver Evans     Answered On: Mar 30

i try to read in java SDK documents and i've found chapter about "executable Jar
Files" in "\j2sdk1.4.0\docs\guide\jar\jarGuide.html"
it says:

On Win32 systems the Java 2 Runtime Environment's installation program will
register a default association for jar  files so that double-clicking a Jar file
on the desktop will automatically run it with javaw -jar. Dependent extensions
bundled with the application will also be loaded automatically. This feature
makes the end-user runtime environment easier to use on Win32 systems

and this executable  was only able for Win32 and Solaris 2.6 kernel.

so i try it and it work. thank you for your appreciation

 
Didn't find what you were looking for? Find more on Executable JAR Or get search suggestion and latest updates.




Tagged: