I am using NetBeans IDE and have created a new project. The new project includes a Main.java.
Is it necessary to have it named Main.java, or can I rename the Main.java into another name? If so, how can I do this? When I try to right-click Main.java, there is no rename option. I thought it was possible.
There should be a menu item called
Refactor --> Rename
Link from NetBeans Wiki
Your name can be anything, as long as you have a
public static void main(String[] args)
in it (This is only if you want this class to be the entry point when you run your application).
You can call the file <whatever you like>.java, but the name of the class in that file must match the new name you give to the file.
So if you rename the file to MyCoolClass.java, you also have to change the class from public class Main to public class MyCoolClass.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With