how to convert .java file to a .class file

.java file is the code file. A .class file is the compiled file.

It’s not exactly “conversion” – it’s compilation. Suppose your file was called “herb.java”, you would write (in the command prompt):

It will create a herb.class file in the current folder.

It is “executable” only if it contains a static void main(String[]) method inside it. If it does, you can execute it by running (again, command prompt:)

Leave a Comment