I want to compile the java but I can’t

Asked

Viewed 98 times

0

Already installed the JDK, JRE, put td q had to put in the path. javac is working but when I give the "java Helloworld" command the following error is displayed: "Error: Could not find or load the main class Helloworld.class".

  package java;

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

That’s the program right there .

pasta onde está o arquivo

  • How you are executing the commands?

  • first gave the javac Helloworld.java,then generated the Helloworld.class,then I give java Helloworld and displays the error

  • ta running from the direct terminal/cmd or an IDE?

  • by command prompt

1 answer

1

Here it worked normally when removing package information:

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

inserir a descrição da imagem aqui

  • I took it anyway I didn’t take it.

  • I’ll change the package

  • @libnarodrigues cannot have package information, remove from code, save it, recompile it, execute it. If so, it will not work at all.

  • is returning the same error,.

  • @libnarodrigues the java and javac commands executed alone return something?

  • yes several things appear.type Usage: javac <options> <source files> Where possible options include: -g Generate all debugging info -g:None Generate no debugging info -g:{Lines,vars source,} Generate only some debugging info -nowarn Generate no warnings -verbose Output messages about what the Compiler is Doing -deprecation Output source Locations Where deprecated Apis are used -classpath <path> Specify Where to find user class files and

  • C: Users adnas Onedrive Desktop java>java web projects Usage: java [-options] class [args...] (to run a class) or java [-options] -jar jarfile [args...] (to run a jar file) where options include: -D32 use a 32-bit data model if available

Show 2 more comments

Browser other questions tagged

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