Home » Newcomers » Newcomers » Create .jar file does not work
Create .jar file does not work [message #167165] |
Thu, 24 August 2006 15:08  |
Eclipse User |
|
|
|
Originally posted by: dgresh.lle.rochester.edu
Hi,
I'm trying to create a .jar file of a package. However, it is not working
for some reason. I right-click the package, and click export. Then, I
click JAR file and follow the instructions.
I tell it to export the package from my workspace. I tell it to export
generated class files and resources, as well as java source files and
resources. I tell it to compress the contents, and add directory entries.
I then specify the filename.
I hit next, and tell it to export class files with compile errors and
warnings.
I hit next, and select my main class from my package. I hit "browse" and
click on GUI, so it sets it to jena.GUI (jena is my package, GUI is my
class). I hit finish.
It creates the .jar file. When I double-click the .jar file, I get a
message saying "Could not find the main class. Program will exit."
What does this mean? What have I done wrong? I have specified my main
class, I have exported the necessary files...what is it complaining about?
It makes no difference if I check the boxes on the first page to export
classpath and .project; the same result happens.
Can someone please offer some advice? Is there something I am missing?
Thanks,
Dan
|
|
| | | | | | | |
Re: Create .jar file does not work [message #167514 is a reply to message #167500] |
Fri, 25 August 2006 15:07   |
Eclipse User |
|
|
|
Originally posted by: dgresh.lle.rochester.edu
I double-click the JAR file in my directory. Also, I have tried running
the JAR from the command line using the java -jar myJar.jar command, and I
get the same error.
Yes, the file has a Main-Class header. There have been some changes:
If I launch GUI.class from the JAR file, it works fine. The GUI displays
and everything in GUI.class works fine. However, if I tell my GUI class to
load another class, DBQuery (which is what I really want it to do), that
makes use of external JAR files, I get the error I mentioned earlier.
The Manifest.mf file has a Main-Class header as I said earlier, but it
does NOT have a Class-Path header. I tried adding the Class-Path header,
and I got the 'Exception in thread "main"' error and all that.
|
|
|
Re: Create .jar file does not work [message #167520 is a reply to message #167514] |
Fri, 25 August 2006 17:07   |
Eclipse User |
|
|
|
Originally posted by: wharley.bea.com
"Dan Gresh" <dgresh@lle.rochester.edu> wrote in message
news:4550f9e0cf58868dbed6c63f5b79d911$1@www.eclipse.org...
>I double-click the JAR file in my directory. Also, I have tried running the
>JAR from the command line using the java -jar myJar.jar command, and I get
>the same error.
>
> Yes, the file has a Main-Class header. There have been some changes:
>
> If I launch GUI.class from the JAR file, it works fine. The GUI displays
> and everything in GUI.class works fine. However, if I tell my GUI class to
> load another class, DBQuery (which is what I really want it to do), that
> makes use of external JAR files, I get the error I mentioned earlier.
> The Manifest.mf file has a Main-Class header as I said earlier, but it
> does NOT have a Class-Path header. I tried adding the Class-Path header,
> and I got the 'Exception in thread "main"' error and all that.
Is it possible that the manifest itself is in the wrong location? Should be
meta-inf/manifest.mf. Might need to be all caps, I can't remember. If you
auto-generated the manifest it should be correct.
Sorry, I don't have many ideas left.
|
|
|
Re: Create .jar file does not work [message #167528 is a reply to message #167417] |
Fri, 25 August 2006 21:27   |
Eclipse User |
|
|
|
Originally posted by: wegener.cboenospam.com
Dan Gresh wrote:
> Hi,
>
> After searching google and stuff, it seems as if it could be a classpath
> error. However, how could this happen? When I create the .jar file, I
> export .classpath and .project, and those files are included in the .jar
> when I view it with WinZip. I have set a bunch of external jars up to my
> project folder's build path. Is there a different way I should be doing
> this?
>
> Thanks,
> Dan
>
If you have dependencies on external jars to run your project, you need
to get them on the class path. They won't be included in the .jar file
that you create.
I'm not an expert on manifest files in .jar files, so I'm not sure
how/if you can specify external .jar files on in the manifest. If not,
you will need to add a -cp {list of jar files} to your command line or
define them in your CLASSPATH environment variable.
|
|
|
Re: Create .jar file does not work [message #167582 is a reply to message #167528] |
Sat, 26 August 2006 16:21   |
Eclipse User |
|
|
|
David Wegener wrote:
> Dan Gresh wrote:
>> Hi,
>>
>> After searching google and stuff, it seems as if it could be a
>> classpath error. However, how could this happen? When I create the
>> .jar file, I export .classpath and .project, and those files are
>> included in the .jar when I view it with WinZip. I have set a bunch of
>> external jars up to my project folder's build path. Is there a
>> different way I should be doing this?
>>
>> Thanks,
>> Dan
>>
> If you have dependencies on external jars to run your project, you need
> to get them on the class path. They won't be included in the .jar file
> that you create.
>
> I'm not an expert on manifest files in .jar files, so I'm not sure
> how/if you can specify external .jar files on in the manifest. If not,
> you will need to add a -cp {list of jar files} to your command line or
> define them in your CLASSPATH environment variable.
I'm not sure you can specify a classpath in the manifest, but I'm pretty
sure you wouldn't want to. If the code in the .jar file depends on any
classes not included in the .jar file, you're relying on the user having
installed them -- but you can't be sure *where* the user installed them.
So it's up to the user to get them on the system CLASSPATH or specify
them with -cp at run time. I think.
/Paul
|
|
| |
Goto Forum:
Current Time: Tue Mar 11 07:20:15 EDT 2025
Powered by FUDForum. Page generated in 0.10988 seconds
|