File . class is not generated

Asked

Viewed 366 times

0

I have already tested, through the command prompt, and java and javac are installed. The problem is that the file .class is not created.

By typing the directory I can find the folder, but not the file I want inside the folder (an error message appears).

  • 1

    Configured the environment variables?

  • 1

    You should [Dit] the question and put more information, like the error that appeared.

  • 1

    Did you compile the. java file? Example: javac SuaClasse.java. The . class files are generated from the build of the . java file

  • If you are starting in Java, I recommend this material: http://www.loiane.com/2013/02/instalando-e-configurando-o-java-no-windows-8/ and also the author’s own video lessons posted at the end of the article.

  • The question should always contain the error, so which error message?

1 answer

2

Your question is unclear but I’ll try to answer anyway.

First create a file HelloWorld.java:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}

And put this file in the folder where you want to compile. Let’s assume that this folder is C:\projetos\helloworld.

Then, at the command prompt, being in the folder C:\projetos\helloworld, you type the following command:

javac HelloWorld.java

And then the file HelloWorld.class should have appeared in the folder. Now you type the following command:

java HelloWorld

And then Hello World should be printed on the console.

If this does not work, let us know what happened unexpectedly and what was the error message, if any. If it works, try to do the same with the program you want to compile.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.