K
K
kuzdman2018-08-13 12:59:48
Java
kuzdman, 2018-08-13 12:59:48

Why is the java code not compiling?

I'm trying to compile this code:

package com.company;

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

Thus:
javac HelloWorld.java
Successful. I launch:
java -classpath . HelloWorld
And then it writes to me: What should I do?
could not find or load main class HelloWorld

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-08-13
@kuzdman

What to do?

It's best to take a textbook. Well, as a last resort, read something about the batch organization of classes and the rules for loading them.
javac -d . HelloWorld.java
java com.company.HelloWorld

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question