Results 1 to 12 of 12
Thread: Eclipse and creating .jar file
- 09-04-2010, 06:07 AM #1
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
Eclipse and creating .jar file
Hi everyone,
I'm really new to java, so if i ask a stupid question, please forgive me.
I created a .jar file by using export function in Eclipse (yes, I include manifest).
When I executed the .jar file on my computer by opening it with java.exe, a error window popped up "couldn't find main class" ; however, I sent this .jar to my gf and she was able to execute the jar file without error by using java.exe
I'm not sure what's wrong this my computer. Have anyone faced this problem before? Please help me out. I would be nice if you guys download the file and run it to see that I was the only person who encountered this problem or not.
I compressed my .jar file into .zip file.
Thx in advance.
PV
- 09-04-2010, 08:35 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,372
- Blog Entries
- 7
- Rep Power
- 17
- 09-04-2010, 10:56 AM #3
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
hi JoSAH,
Is the OS that runs my .jar file 32 bit?
There is nothing wrong with my associate file. Somehow the .jar file can be executed on 32bit system ( my gf's wins 7 32 bit, wins 7 32 bit on my laptop, and Virtual machine wins 7 32 bit on my 64 bit OS). Only my wins 7 64 bit can't run this .jar file.
Does this mean we can't run .jar on Wins 7 64 bit ???:confused:
- 09-04-2010, 01:38 PM #4
How did you verify that? On WinXP you can look at the OS's file association table by:There is nothing wrong with my associate file
Open Windows Explorer
Click on Tools menu
Click on Folder Options
Select File Types tab
Scroll down in the "Registered file types:" list until you see an entry for JAR.
Select the JAR entry.
Click the Advanced button
In the Edit File Type window scroll down the list of Actions until you see the one in bold.
Select the bold one
Click the Edit button
Select, Copy and paste here what is in the "Application used to perform action:" window.
Be careful not to change anything and Cancel your way out of the open windows.
If you copy the commandline from above, open a commandprompt window, change tothe folder with the jar file, paste the commandline to the command prompt, change the %1 to your jar file name and press enter, What happens?
- 09-04-2010, 04:31 PM #5
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
Hi Norm,
I did verify the file associate. On Wins 7, right click > properties > under General tab, click the Change button to select a program> select java or javaw or the fullpath C:\Program Files\Java\jre6\bin\java.exe
In command line: error for both cases: Could not find the main class: blablabla. Program will exit.
So I think I will use my virtual machine to create and test .jar files then. :)
- 09-04-2010, 05:17 PM #6
What is the contents of that window? Does it have a -jar in the command line???Copy and paste here what is in the "Application used to perform action:" window.
It would help if you copied and pasted here THE EXACT contents of the error message.error for both cases: Could not find the main class: blablabla.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
There could be a problem with the manifest file: misspelled classname, wrong package, ??
Look in the jar file at its manifest file. Copy and paste here the contents of the manifest file from the jar file.
Here's one way to get the error message. The full text of which shows the error.
D:\JavaDevelopment\Testing\ForumQuestions3>java asdfas <<<<<<<<<<< NOTE class name is invalid
Exception in thread "main" java.lang.NoClassDefFoundError: asdfas
Caused by: java.lang.ClassNotFoundException: asdfas
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: asdfas. Program will exit. <<<<<<<<<<< Here is some of what you gave us
D:\JavaDevelopment\Testing\ForumQuestions3>Last edited by Norm; 09-04-2010 at 05:29 PM.
- 09-04-2010, 07:10 PM #7
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
Here is the content of the error. I didn't put -jar in the command line
C:\Program Files\Java\jre6\bin>java.exe Users/phatvi/Desktop/sharefolder/ATMBank
Account.jar
Exception in thread "main" java.lang.NoClassDefFoundError: Users/phatvi/Desktop/
sharefolder/ATMBankAccount/jar
Caused by: java.lang.ClassNotFoundException: Users.phatvi.Desktop.sharefolder.AT
MBankAccount.jar
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: Users/phatvi/Desktop/sharefolder/ATMBankAccount.j
ar. Program will exit.
For manifest content
Manifest-Version: 1.0
Main-Class: ATMBankAccount
- 09-04-2010, 07:16 PM #8
why not? Read the API doc for how to use the java command. Its necessary.I didn't put -jar in the command line
Does the name of the class not found look familiar?NoClassDefFoundError: Users/phatvi/Desktop/sharefolder/ATMBankAccount/jar
The java command takes the name of a class as an arg.
you passed the command a path to a file which the java command assumed was the name of a class file.
- 09-04-2010, 10:42 PM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,372
- Blog Entries
- 7
- Rep Power
- 17
- 09-04-2010, 11:43 PM #10
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
Norm and JosAH,
Thx for the help. I just figured out what's wrong with my command line.
This command line works for me
All I wonder now is why I can't execute the .jar file with just with a double click as other computers?cd [filepath]
[filepath] > java - jar ATMBankAccount.jar
- 09-04-2010, 11:48 PM #11
That problem was discussed in post#4.
There needs to be a correct entry in the OSs filetype association table.
Selecting a program is NOT the same as creating a command line. You need the -jar option.
- 09-04-2010, 11:51 PM #12
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
creating war file in eclipse
By pelegk1 in forum EclipseReplies: 3Last Post: 05-24-2010, 04:28 AM -
Creating .xml files in eclipse
By lheebhee in forum EclipseReplies: 1Last Post: 11-17-2009, 06:48 AM -
Creating a JEE project in eclipse with JBoss
By vertho in forum EclipseReplies: 0Last Post: 05-28-2008, 10:36 AM


LinkBack URL
About LinkBacks


Bookmarks