Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Trouble exporting .jar file(unable to run jar file by double-clicking)
Trouble exporting .jar file [message #898984] Mon, 30 July 2012 01:53 Go to next message
Nigel Cunliffe is currently offline Nigel Cunliffe
Messages: 2
Registered: July 2012
Junior Member
Hi. In the process of learning Java I have mainly been making very simple programs. But now I actually have a project, still in progress, that I am very proud of so far. Anyways I would like to export it as a JAR file(its a game), but I seem to be failing to do so. What I do is, File> Export> JAR file.

I choose a name and location for the jar (same folder as src, images, etc). I then choose "Generate manifest file" and choose my main class and hit finish. I would upload some screenshots but I can't on this forum for some reason.

I get a popup saying "JAR export finished without warnings" and everything seems good. But when I try to run it, I get this error: "Could not find the main class: (class name) Program will exit"
I have searched a few forums with people having the same problem, but none of their solutions have seemed to work for me (or I am just doing something wrong). One thing I read is that it could be something with the Environment Variables path. I am aware of how to edit it, but I am not exactly sure what I would need to change (or if it even really matters). The program I am trying to export also uses images and reads info from a txt file. Not really sure if thats a big deal either. Also uses no external libraries or anything like that, just pure Java.

I have also tried exporting is as a "Runnable JAR" but I get the same error after getting the same confirmation that it compiled fine. Also, I think I should add that running the JAR or Runnable JAR through command line works fine, but I would really like to be able to distribute this to others. Also Im using Eclipse Indigo and running JDK7/JRE7

As you can probably tell I am a total n00b and if anyone can walk me through what I should do in the simplest possible way, I would really really appreciate it. Thanks people! =)
Re: Trouble exporting .jar file [message #899064 is a reply to message #898984] Mon, 30 July 2012 12:22 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
On 30.07.2012 03:53, Nigel Cunliffe wrote:
> Hi. In the process of learning Java I have mainly been making very
> simple programs. But now I actually have a project, still in progress,
> that I am very proud of so far. Anyways I would like to export it as a
> JAR file(its a game), but I seem to be failing to do so. What I do is,
> File> Export> JAR file.
>
> I choose a name and location for the jar (same folder as src, images,
> etc). I then choose "Generate manifest file" and choose my main class
> and hit finish. I would upload some screenshots but I can't on this
> forum for some reason.
>
> I get a popup saying "JAR export finished without warnings" and
> everything seems good. But when I try to run it, I get this error:
> "Could not find the main class: (class name) Program will exit"
Make sure to run it with java[w] -jar <your JAR>

Dani
> I have searched a few forums with people having the same problem, but
> none of their solutions have seemed to work for me (or I am just doing
> something wrong). One thing I read is that it could be something with
> the Environment Variables path. I am aware of how to edit it, but I am
> not exactly sure what I would need to change (or if it even really
> matters). The program I am trying to export also uses images and reads
> info from a txt file. Not really sure if thats a big deal either. Also
> uses no external libraries or anything like that, just pure Java.
>
> I have also tried exporting is as a "Runnable JAR" but I get the same
> error after getting the same confirmation that it compiled fine. Also,
> I think I should add that running the JAR or Runnable JAR through
> command line works fine, but I would really like to be able to
> distribute this to others. Also Im using Eclipse Indigo and running
> JDK7/JRE7
>
> As you can probably tell I am a total n00b and if anyone can walk me
> through what I should do in the simplest possible way, I would really
> really appreciate it. Thanks people! =)
Re: Trouble exporting .jar file [message #899188 is a reply to message #898984] Tue, 31 July 2012 00:15 Go to previous message
Nigel Cunliffe is currently offline Nigel Cunliffe
Messages: 2
Registered: July 2012
Junior Member
yeah I was saying it works fine when I run it through command line. But not when I double click the jar file. I would like to be able to send this to others but not everyone knows how to run through command line. Most people probably don't even know what that is.
Previous Topic:Syntax Coloring in JSP Scriptlets.
Next Topic:How to customize the entries on File -> New
Goto Forum:
  


Current Time: Tue Sep 16 07:33:07 GMT 2014

Powered by FUDForum. Page generated in 0.02030 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software