Issue
I am extremely new to java programming. I just installed java on my PC and installed Apache NetBeans for Java Programming. I created a single 'Main.java' file and put the following code in it:
public class Main {
public static void main(String[] args) {
String greeting = "Hello!";
System.out.println(greeting);
}
}
And when I click on the 'Run' button at the top, most of the buttons are greyed out including the compile button. See this screenshot:
I can run this code because the 'Run File' button can be clicked. But I cannot create a .exe file from it, because the 'Compile File' button is greyed out. How can I fix it? Thanks!
Solution
Don't go for exe now :( When you compile your java program (.java) it will be converted into a bytecode (.class) file which is executed(interpreted) by JVM(Java Virtual Machine) and you get the result so java is known as a platform-independent language. So learn basic like operators, conditions, loops, OOP concepts, Exception handling, file handling, Collection framework, and some GUI (if you want) and check output there as you do in IDE, grasp concept like JVM and how it works, Why do we need it ?, JRE, etc etc and later you will understand everything.
In case you need it:
Make a JAR file for your application
Download Launch4J from (http://launch4j.sourceforge.net/)
Compile and Make Executable from Launch4J. For reference:
I highly recommend you to compile and run your program from your IDE at least for now.
Answered By - AcKuber