Command line

Ok, suppose when i jar all my files i use command line and type this:

jar cf MyJAR.jar class1.class class2.class class3.class class4.class class5.class class6.class …

is there a way to put that whole thing inside a file and execute that file? instead of typing that every time?

Dump that into a .bat file (make one in notepad) and add “pause” as the second line so you can capture output.

  • Jon

You might also consider using an IDE, like Eclipse, with Ant build files that you can write to do that kind of packaging (and a lot more ).

Thanx, Jon, it worked.

[quote]You might also consider using an IDE, like Eclipse, with Ant build files that you can write to do that kind of packaging (and a lot more ).
[/quote]
I use JCreator and it doesnt support jarring.

A simple way in Jcreator is to add a bat file as external tool: configure->option->tools->new->program than add a bat file like this:

makeJar.bat


pushd
cd classes
jar cf output.jar *
popd
pause

once you have done it, simply add this external tools to your toolbar:
right click on toolbar->customise select categorie “Tools” drag first tools icon to your toolbar.

you may also use/customise this tools http://www.java-gaming.org/forums/index.php?topic=17584.0 to make exacly what you want as for example read filename from a txt file as requiered by your first post.

You could use

jar @arglist.txt

where “arglist.txt” is a file containing

cf MyJAR.jar class1.class class2.class etc

spread over multiple lines if you like. (See the jar tool documentation, e.g., http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/jar.html.)

But you may find that batch files may give you more flexibility.
Simon

Learning ant http://ant.apache.org/manual/index.html would give you a lot of flexibility and the accuired knowledge should be useful anyway, since it is pretty much standard for building/packaging java projects. I don’t know use JCreator (and would advice using Netbeans or Eclipse), but there is at least some ant integration mentioned on the features page (apparently pro only). Also adding the ant-execution via configure->option->tools->new->program might always be an option.