creación de archivos jar

I am trying to create a jar file with many classes. Using the following command

C:\Users\use\Desktop\SDE_7_SSH\eclipse\new\charge\src\jar> jar cf charge.jar *.class

But it is throwing an error 'jar' is not recognized as an internal or external command, operable program or batch file.

In my jar folder (C:\Users\use\Desktop\SDE_7_SSH\eclipse\new\charge\src\jar), i am having two other folders named "f1", "f2", which inturn having classes.

preguntado el 24 de agosto de 12 a las 06:08

When i try to use the following command, i am getting the error respectively C:\Users\use\Desktop\SDE_7_SSH\eclipse\new\charge\src\jar>java -jar cf charge.jar *.class Error: Unable to access jarfile cf it is -

3 Respuestas

You need to run the jar command from bin directory. For example on linux system, I would either go to my directory

cd /usr/local/java/jdk1.6.0_01/bin/

Y luego ejecutar

jar cf charge.jar *.class

or else run it with the full path of java binary

/usr/local/java/jdk1.6.0_01/bin/jar cf charge.jar *.class

Respondido 24 ago 12, 07:08

Use 'java -jar' Not just 'jar'

Respondido 24 ago 12, 06:08

When i try to use the following command, i am getting the error respectively C:\Users\use\Desktop\SDE_7_SSH\eclipse\new\charge\src\jar>java -jar cf charge.jar *.class Error: Unable to access jarfile cf it is - BKK

java -jar is used to execute a JAR archive not to create one. - arrastrar

Use the complete path to the jar program, which is in Java's bin directory. Like

jdk_with_version\bin\jar cvf *.class

Respondido 24 ago 12, 06:08

Since i am new to java, can you give me detailed example - BKK

Follo this link (www.cis.upenn.edu/~matuszek/cit594-2002/Pages/jar-files.html) this could help you to solve - gks

i am able to create jar file. But after adding the jar file to my project it is showing class not found errors. I checked my jar files by using the command D:\charge>D:\rrr\bkk\"core java"\software\Java\Java_1.6.0_ 04_win\jdk1.6.0_04\bin\jar xvf charge.jar. It is having the .java files, but i am getting class not found error in my project. - BKK

Extract your jar and see whether you could find the classes which your looking for? - gks

Make sure whether you have added the jar file to the classpath in run configurations and execute - gks

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.