Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Command Line Jar File

I've created a few .jar files (using Eclipse's export feature), but they were all GUIs. I want to create a .jar file that is strictly command-line; is this possible?

like image 755
Pandemic Avatar asked Jan 20 '10 16:01

Pandemic


People also ask

What is Java jar command?

The jar command is a general-purpose archiving and compression tool, based on the ZIP and ZLIB compression formats. Initially, the jar command was designed to package Java applets (not supported since JDK 11) or applications; however, beginning with JDK 9, users can use the jar command to create modular JARs.

How do I import a JAR file in Terminal?

jar " from command line : " -classpath lib/ ", " -classpath ./lib/ ", " -classpath lib ", " -cp lib/* ", " -cp lib/\* ", " -classpath lib/referenced-class. jar ", " -classpath ./lib/referenced-class. jar " (lib is where the referenced jar resides)


1 Answers

There is no such thing as a "GUI jar" or a "command line jar". If you want a program to work on the command line, then you read and write the from System.in and System.out or files rather than using Swing or AWT.

If on the other hand you are asking how to create a jar on the command line, the command is, not too surprisingly "jar". As in jar cf foo.jar com/my/foo/*.class

like image 176
Paul Tomblin Avatar answered Sep 28 '22 07:09

Paul Tomblin