Java Should the project name of my Java application ?

Click For Summary
The project name of a Java application does not need to match the filename when saving the application. In the case discussed, the project was named "First Java Program," while the file was saved as "GetStarted.java," which is acceptable. To compile the Java application in NetBeans IDE 8.0.2, simply press the green triangle button. If the file contains a class named GetStarted with a main method, it will compile successfully. Confirmation of a successful build is indicated by the message "BUILD SUCCESSFUL." To execute the application, pressing the same green button will run the program, and any output from the main method should be visible in the output window.
Math10
Messages
301
Reaction score
0
Should the project name of my Java application must be the same as the name when I save my Java application? Because I'm using Netbeans IDE 8.0.2 and in the project name field, I put First Java Program and after I wrote the Java application, when I save it, I put GetStarted.java in the save as field. Is this okay? And how do I compile my Java application from here?
 
Technology news on Phys.org
No, not necessarily.

You have a class named GetStarted in the file GetStarted.java, right? If it is your only class and there is a main method within that class you can compile it by just pressing the green button that has the shape of a triangle. In your case Netbeans will configure the compiler to compile said file (GetStarted.java). If you have more than one class with a main method, Netbeans will ask you which one you want to compile.
 
Thank you for the help. I did as you said and got
run:
BUILD SUCCESSFUL (total time: 0 seconds)
in the output window in my IDE. So did I did this right?
 
Yes, you did it right. ;)

However, if there was some code that printed text on the screen on the main method within GetStarted.java you should have seen that too.
 
So in order to run (execute) a Java application, just press the green button that looks like a triangle and you're done, right?
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
7K
Replies
8
Views
2K
  • · Replies 25 ·
Replies
25
Views
3K
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
6K
Replies
3
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
Replies
11
Views
3K
  • · Replies 4 ·
Replies
4
Views
5K