Runnable jar file generated by Eclipse won't execute?

Jars are never 'executable' in this sense. What this jar is good for is.

Up vote 1 down vote favorite share g+ share fb share tw.

I generated a very simple runnable jar file using Eclipse's "Export-->Java-->Runnable Jar File" function. My HelloWorld class looks like this: import javax.swing. JFrame; public class HWorld extends JFrame { public static void main(String args) { new HWorld(); } public HWorld() { this.

SetSize(200, 100); this. SetDefaultCloseOperation(JFrame. EXIT_ON_CLOSE); this.

SetTitle(""); this. SetVisible(true); } } Now, after generating the . Jar file , it runs fine from the command line using the command "java -jar HWorld.

Jar" But, when I try to execute the jar on its own (which supposedly should work) I get the following error and I don't know why: E:\Eclipse\workspace>HWorld. Jar Exception in thread "main" java.lang. NoClassDefFoundError: E:\Eclipse\workspace\HWorld/jar Caused by: java.lang.

ClassNotFoundException: E:\Eclipse\workspace\HWorld. Jar at java.net. URLClassLoader$1.

Run(URLClassLoader. Java:200) at java.security. AccessController.

DoPrivileged(Native Method) at java.net.URLClassLoader. FindClass(URLClassLoader. Java:188) at java.lang.ClassLoader.

LoadClass(ClassLoader. Java:307) at sun.misc. Launcher$AppClassLoader.

LoadClass(Launcher. Java:301) at java.lang.ClassLoader. LoadClass(ClassLoader.

Java:252) at java.lang.ClassLoader. LoadClassInternal(ClassLoader. Java:320) Could not find the main class: E:\Eclipse\workspace\HWorld.jar.

Program will exit. My manifest looks like this: Manifest-Version: 1.0 Rsrc-Class-Path: . / Class-Path: .

Rsrc-Main-Class: HWorld Main-Class: org.eclipse.jdt.internal.jarinjarloader. JarRsrcLoader The only thing that looks really fishy to me is this (since a . Jar is not a .

Class): Could not find the main class: E:\Eclipse\workspace\HWorld. Jar Looking for ideas or thoughts or even an answer! I tried to give as much info as possible in hope of a quality answer.

This thread implies that it should work but doesn't answer my question: http://forums.oracle.com/forums/thread.jspa?threadID=2152988 . Can anyone else try it in their Eclipse? Eclipse jar executable-jar link|improve this question edited Feb 3 '11 at 17:32 asked Feb 2 '11 at 23:24djangofan1,40511137 78% accept rate.

From bmargulies comment (below) , it appears that windows is passing in the path of the jar file name in the same way that it would if you typed "myfile. Txt" at the command line: windows would try to open it like "notepad. Exe c:\path\myfile.

Txt". This makes me believe that this self launching . Jar might not be possible.

– djangofan Feb 3 '11 at 18:26.

Jars are never 'executable' in this sense. What this jar is good for is: java -jar YOURJAR. Jar update the backtrace you supplied is bizarre.

It appears that Windows decided to go ahead and launch your jar with some version of Java, but pass it a pathname in the place of a class name. I don't know what the story is with that.

The jar contains the org.eclipse.jdt.internal. Jarinjarloader classes and so IT IS launchable this way, or so it appears that it should be. (read the manifest file entries above) – djangofan Feb 2 '11 at 23:44 im not too sure about your answer and at the same time I believe it.

Now, when I execute the . Jar file without using "java" then , how is it that the interpreter seems to be running? It seems to me that it must be working to a certain degree?

– djangofan Feb 3 '11 at 0:00 @dja sure 'nuf. See my edit. – bmargulies Feb 3 '11 at 1:51 yeah, I see what you mean.

In the manifest I am certainly using ". /" for local directory and it looks like the jarinjarloader is translating it into an absolute path. I might try to find the source code for "jarinjarloader" if thats possible.

– djangofan Feb 3 '11 at 5:12 since jarinjarloader is something created at IBM, I tried downloading the IBM version of Eclipse but it doesn't contain the Export runnable jar option. – djangofan Feb 3 '11 at 5:47.

Uninstalling all older java versions on my machine fixed the issue for me. At my end I was able to run the . Jar file with the command line, but not with the default double-click option.

Afterwards the latter was working again.

Uninstalling all older java versions on my machine fixed the issue for me.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions