0

I'm trying to run a jar file from command line on Windows using:

java -cp .;C:\java\empacotadoJars\Empac.jar;C:\java\empacotadoJars\ClienteEmpacotado.jar ClienteEmpacotado

It raises the exception:

Could not find or load main class ClienteEmpacotado

The classes are:

public class Empacotado{
    public static void escrever(){
      System.out.println("Chamndo metodo de classe Empacotado!");
    }
}

public class ClienteEmpacotado{
   public static void main(String args[]){
      Empacotado.escrever(); 
   }

}

Empacotado.class is inside Empac.jar and ClienteEmpacotado.class is inside ClienteEmpacotado.jar. I first zipped each one and then renamed to jar extension. Inside ClienteEmpacotado.jar I created META-INF folder with MANIFEST.MF file, which contains:

Manifest-Version: 1.0
Main-Class: ClienteEmpacotado

What might be wrong?

Rumpelstiltskin
  • 273
  • 1
  • 3
  • 9
  • syntax for running jars: `java -jar myjar.jar` or `java -cp jarfiles.jar my.package.class` see http://stackoverflow.com/questions/1238145/how-to-run-a-jar-file – vandale Nov 03 '13 at 19:35
  • Not much point in creating a main-class attribute if you're not going to use it. Use java -jar, and put a Class-path attribute in the manifest as well. – user207421 Nov 03 '13 at 21:04

1 Answers1

0

The problem was that I had used Winrar to make the zip files (then I renamed to jar extension). Using "jar cvf Package.jar Arq.class" to make the jars solved.

Rumpelstiltskin
  • 273
  • 1
  • 3
  • 9