How Do You Run a Java Program That Has Compiled Successfully?

Problem scenario
You have compiled the source code of a Java program into bytecode (with a .class extension). You try to run it (execute the bytecode) with a javac command (javac HelloWorld), but you get "error: Class names, 'HelloWorld', are only accepted if annotation processing is explicitly requested
1 error "

What should you do?

Solution
Run it with the java command like this (with no ".class" extension): java HelloWorld

Leave a comment

Your email address will not be published. Required fields are marked *