I am not getting any output when I try to run the .class File that was created from my .java file in terminal. The code is compiling just not printing [closed]

This is what I have done in the terminal. I have tried compiling the .java file and it compiles fine because it is creating a .class file I am unsure as to why the .class file is not being executed.


The class name in your code, is a different name from your file name, for example if I am making a new file with the name HelloWorld.java, my code should be like this

class HelloWorld
//your code

it shouldn’t have a different class name. even the case should be correct.

To fix your problem, just open your HelloWorld.java file, and change the class name from Main to HelloWorld it will work!!

All the best learning java! its a great language..

Leave a Reply

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