This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes executable java files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "executable java files" Watch "executable java files" New topic
Author

executable java files

Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
so i made a jar archive and it works just fine on my box at work and at home.

i just emailed it to someone and they get an error like :"can't find main class".

in the manifest file i have(with new line feed): Main-Class: CiscoProfiles

and that's it. again, works on computer at work and home, but not someone else's work computer.

the only difference is that mine has sdk, where theirs only has jre.

so, does the jre run jar files??? if not, then how do I get the jar file to be executable on people's computers without having to install the sdk AND without having to install other software?


Scooby Snacks for everyone...<br /> <br />SCJA, SCJP 1.4
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
do i need to modify my manifest file to include ./Ciscoprofiles ?

i don't want to try again until i know how things work
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
anyone?

to run an executable jar does one need the sdk, or is the jre enough? and if the latter is true, is there supposed to be special configurtion?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41029
    
  43
PatienceIsAVirtue

The JRE is sufficient, and it should not require any special setup. How are they trying to run this file? What is the exact error message?


Ping & DNS - my free Android networking tools app
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Main-Class: CiscoProfiles

Is your class in a package? You need to specify the fully qualified name (including the package name) in the manifest file.

Also, does the manifest file end with a newline? Note what this tutorial says:
Warning: The text file from which you are creating the manifest must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
Originally posted by Ulf Dittmer:
PatienceIsAVirtue

The JRE is sufficient, and it should not require any special setup. How are they trying to run this file? What is the exact error message?




thanks everyone for the response...i submitted it to someone as if it were good as gold and ready to be deployed, only to find out that the first person I tried it on did not work, so that i'm freaking out.


they have JRE installed for sure. the error is the infamous:""Could not find main class. Program will exit." " i just tried it on another work computer with the same JRE (1.4.2) and same error message. this means that every computer in the company can't run this executable JAR now most likely. all have windows XP.


again, it's an executable jar so i'm just having them double click it. i compiled it with jar cvfm.... works at home on 3 computers now (2 with sdk and one 1 jre) simply double clicking it. it has the manifest file in it and two class files. those 3 computers at home are also windows xp. the one 1 with only JRE MAy have had sdk installed at one point.


the two class files are not in packages and even if they were, why would it work at home and not at work if that were an issue??? manifest file is:

and that's it. new line of course. is it missing somethign that would only work on certain JRes? works got java ver 1.4.2 and I got the new 1.6 update2 or whatever it's called now.




what's the deal here? why can't i run this at work? any ideas are welcomed.
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
on the computers it doesn't work on i noticed the icon is that of like a blank document, not a java file. my work computer (has sdk) and ones at home show the java symbol on the file.

however, the ones it doesn't work on does say it's an executable jar file, so it seems windows is recognizing the file type and that it's marked as executable, just the JRE class loader can't find main. sounds like a java JRE issue, not windows or my code.



just some more information. and someone asked me why i didn't use a MS batch file instead...
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
yeah, i updated the JRE ONLY on one of the machines my program didn't work on to 1.6 JRE and now my program (jar) has the java symbol and works.



--------------------------------------------
so, now it's not me for sure, and it's the JRE on these computers. what could possibly be done to the 1.4 JRE install to prevent my program from running?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: executable java files
 
Similar Threads
Compiling and other questions
jar files inside executable jar file
executable jar file problem
Jars inside one jar?
Jar file exception due to not finding Oracle driver but other standalone programs can use it