Java is a highly preferred language amidst coders and developers. Java has gained immense popularity over the years. Java is a flexible language offering multiple supports and features. It is the most suitable language to draft projects and models. Creating, executing and packing projects in java follow very simple rules. You could use multiple text editors to write and compile codes. All text editors follow very simple rules for creating a project in java. To master Java, you need to take Java training. After that you will be able to create anything in Java. Here is the guide to creating a simple project in Java:
Creating a new project:
There are multiple text editors and compilers that help you write and execute codes of java language, all of these follow the same rules and protocols. These text editors help you source code, tests, libraries that you use, build instructions and insert your personal settings in a single unit. Some of the text editors that you can use are eclipse, IntelliJ IDEA, or even as basic as a notepad. Let’s see how you can create a new project using any of the text editors.
- Launch your text editor. A welcome screen is displayed, on this screen find the option of a new project and click ok. You can also browse the main menu for the file option and choose a new project from there.
- Now choose java from the new project list in the wizard window.
- To develop any project in java text editors you are required to possess, java SDK or JDK. Download the JDK and SDK directory to include in your script.
- If you wish to work on any other directory/library, you could similarly include those as well.
- Now provide a name to the project and click finish.
Creating and packaging a class:
Now before initiating any project, you are required to package similar classes together.
- Go to the project tool window, and right-click on the src folder, and select new.
- Now select java class.
- In the name field that is projected to you type “com.filename” and click OK.
- Now your class is created and your code would be compiled based on these similar structures and classes.
Write the code for your first project:
- place the caret at the class declaration position after opening a curly bracket({ ) and press shift+ enter.
- Type main and select the template that inserts the main() method declaration.
- Similarly you can choose various templates to write then code in java.
- After the main() method use the system class(sy) from the list of codes in the java.lang package. Press ctrl+. To insert the selection.
- Now type p, select the printLn(string X) method to write code.
Compile and execute your code:
- Now click on the gutter and select run “filename.main()” in the popup. The IDE starts compiling your code once compiled.
- The run tool window appears, the first line of which depicts the compiling command and class. And your code’s output Is displayed after that.