Could not find or load main class file.java

0

Hi,

I've been trying to make a code run in a new environment, but I'm not having success.

Whenever I open cmd and run java arquivo.java , I get the Não foi possível localizar nem carregar a classe principal arquivo.java error.

The class has already been compiled without any problem and, theoretically, everything is fine.

My environment variables:

JAVA_HOME :

  

C: \ Program Files \ Java \ jdk1.8.0_05

CLASSPATH :

  JAVA_HOME% \ lib \ tools.jar;% JAVA_HOME% \ lib \ dt.jar;% JAVA_HOME% \ lib \ htmlconverter.jar;% JAVA_HOME% \ jre \ lib;% JAVA_HOME% JAVA_HOME% \ jre \ lib \ rt.jar;

PATH :

  

* irrelevant variables *;% JAVA_HOME% \ bin

Any idea what I might be doing wrong?

    
asked by anonymous 15.12.2015 / 23:21

1 answer

2

It is necessary to compile the class before running.

And to run, the class must contain the main method.

Ex:

public class Arquivo {
  public static void main(String args[]) { 

  }
}

Command to compile

javac Arquivo.java

Command to run, but can not and does not need to use extension.

java Arquivo
    
15.12.2015 / 23:27