Help - Search - Members - Calendar
Full Version: Jar Files
JCreator Forum Board > JCreator > General
gpcprog
Does any one know how to create JAR files with JCreator. I tried it, it made a JAR file, but when I tried to execute it, it said that the Main Class was not found. I tried to mess with the mainfest file, but nothing helped. So in the mean time I am using NetBeans, but my comp is kind of old, so it doesn't work well.
jeef
have you got your package set properly? the jar archive will need packages to be in folders within the jar. and (i think) the manifest needs to specify which class to execute the "static main void(String args[])" from
E-E-R
A working Manifest:
CODE
Manifest-Version: 1.0
Created-By: 1.5.0 (Sun Microsystems Inc.)
Main-Class: RC5StatsFrame



please note the two <ENTER>s after the last attribute, they are mandatory, or it won't work.
docevi1
no no, I can make jar files using the command line fine, but can JCreator make them automatically using the way it's set up.

Seems strange that it can't hence my asking.

thanks for the reply either way
E-E-R
It cannot make executable jar files directly, you would have to change the parameters JCreator uses to create a jar file to match those you use from the command line (since that works).

Configure
> Options
> + next to Tools
> create Jar File
> somewhere on the right you can fill in the parameters
twinbee
It'd be nice if JCreator could automatically create JAR and EXE files for the next version of JCreator. Unless that'll bloat the software.

Here's hoping!
evdg
QUOTE(twinbee @ Mar 31 2005, 04:04 PM)
It'd be nice if JCreator could automatically create JAR and EXE files for the next version of JCreator. Unless that'll bloat the software.

Here's hoping!
*



Exactly what I asked for. I used to use JBuilder and the one cool feature that I liked was that it could build complete self contained project jar files.

I now have a trick, have written a very simple .cmd file which has project related entries and I call this from withing jcreator to build my 'customised' project libraries.

Abyzmic
QUOTE(evdg @ Mar 31 2005, 09:57 AM)
Exactly what I asked for. I used to use JBuilder and the one cool feature that I liked was that it could build complete self contained project jar files.

I now have a trick, have written a very simple .cmd file which has project related entries and I call this from withing jcreator to build my 'customised' project libraries.
*



You should post your .cmd file contents so people can use it too :P
javacollege
QUOTE(gpcprog @ Mar 27 2005, 06:49 PM)
Does any one know how to create JAR files with JCreator.  I tried it, it made a JAR file, but when I tried to execute it, it said that the Main Class was not found.  I tried to mess with the mainfest file, but nothing helped.  So in the mean time I am using NetBeans, but my comp is kind of old, so it doesn't work well.
*



=============================================
I have encountered the same problem. Clearly it is malfuction on part of JCreator and has to be fixed as soon as possible!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
xinox
Open the jar file with an archive utility and check if it has the corresponding main class included.
lordSauron
I tried to make a jar file too... It ATE an entire file <sob>.

Post that .cmd file, and Xinox... you need to fix up this problem - really bad. I tried making a new tool to create a jar file. The default user tool for creating a jarfile murdered my source code. I shouldn't need to be a ph.d to create a jar file, especially when JBuilder can make one out of a project just like that. If I were Xinox, I'd be very embarrassed this error had persisted long enough to weasle into a whole product release!
E-E-R
lordSauron >
there is nothing wrong with the default jar creation script that is default in JCreator. I have used it for some time now and it works perfectly. It does exactly what it says it does: 'create a JAR file'.

I do not know how you have managed to destroy your source code using the jar tool, but the default JAR creation script is all right.

If you would like to know how to configure JCreator to create an executable JAR file, please read this topic for detailed instructions.
Phil^
QUOTE(lordSauron @ Apr 5 2005, 08:45 PM)
I tried to make a jar file too... It ATE an entire file <sob>.

Post that .cmd file, and Xinox... you need to fix up this problem - really bad.  I tried making a new tool to create a jar file.  The default user tool for creating a jarfile murdered my source code.  I shouldn't need to be a ph.d to create a jar file, especially when JBuilder can make one out of a project just like that.  If I were Xinox, I'd be very embarrassed this error had persisted long enough to weasle into a whole product release!
*



from what i can gather, all that JCreator does is call jar.exe with some parameters to make the jar file.
Its sun microsystems your rage should be directed at for eating the source code , not xinox :)
lordSauron
True, I was vauge.

Xinox should have a tool to create a jar file out of a project - a self-executing jar file. I shouldn't have to fool around with all this manifest nonsense! I mean, JBuilder found it such a small feature they didn't even bother to note it in the advertising (JBuilder 4). It can't be that difficult... I know I'm ignorant, but hey, it's real bliss. I don't want to learn how to create a manifest file!!! Forget saving the whales, save my ignorance!
mko
After adding the crate jar file tool (explained bafore) you have to add a new file to the project. Right click on the project name->add new file. Name it "Manifest.txt".
in this file write:
Main-Class: MyPackage.MyClass

MyClass y the entry point to the jar file where the main method is. The text file must end with a new line or carriage return. This is very important or it won't work.
Save the file.

Now Configure->Options->+Tools->Create Jar File:

In the argumentrs field paste this:
cmf Manifest.txt $[PrjName].jar . .The dot after ...].jar must be pasted too.

That should work. It did work for me.
lordSauron
Thanks for two things:

1) telling me how. I would have never figured that out.
2) proving my point that it's really quite a bit to do just to make a jar file.
evdg
Sorry for not coming back earlier, don't read the forum often enough and did not think it too important.

anyway,

save this as a file e.g. BuildProjectJar.cmd

goto %1
goto end
:Dummy
del %2\..\..\ProjectJars\Dummy.jar
jar cvf %2\..\..\ProjectJars\Dummy.jar -C classes /it/jrc/dummy -C ../Other/classes it/jrc/other
goto end
:LSAParser
del %2\..\..\ProjectJars\LSAParser.jar
jar cvfm %2\..\..\ProjectJars\LSAParser.jar manifest.mf -C classes /it/jrc/lsa
goto end
:end

Of course your directory structure may vary, I just have one dir where I jar all my projects, this dir then contains the latest builds.

Setup the tool in JCreator to run this file and take the project name, project dir as the parameters.

arguments: $[PrjName] $[PrjDir]
initial directory: $[PrjDir]

You do have to manually insert an entry into this file for each project (obviously)

Because you control the jar cvf line, you control the inclusion of the manifest (second example)

The only problem I found was the -C directive in the jar line, which does not do what you expect. -C does not 'change' directory, it only does it for the next file (or dir)

What I am trying to say is that if you want to get 2 class files from a different dir, you have to prefix them both with -C somedir otherwise you will not get what you want.

This here works for me, but is really very simple..

Oh, and the manifest file for nr 2 looks like

--
Manifest-Version: 1.0
Main-Class: it.jrc.lsa.ParserTest

--

3 lines!! the CR at the end is important

Erik
amdmatt
sorry for the major bump but..

i tried making the jar file using the manifest.txt and im pretty sure i did everything right.. is there something wrong with what is written there? i can't use a command line jar maker becuase this is for school and all the comps are monitored and deepfroze and crazy stuff..
help thanks
E-E-R
it's a MANIFEST.MF

that might be a problem, but I'm not sure.

if you renamed it MANIFEST.MF and got it in the jar file in the dir META-INF and it still doesn't work, please post your MANIFEST.MF file here
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.