How To Make Your First Project In Java

How To Make Your First Project In Java

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.

  1. 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.
  2. Now choose java from the new project list in the wizard window.
  3. 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.
  4. If you wish to work on any other directory/library, you could similarly include those as well.
  5. 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.

  1. Go to the project tool window, and right-click on the src folder, and select new.
  2. Now select java class.
  3. In the name field that is projected to you type “com.filename” and click OK.
  4. 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:

  1. place the caret at the class declaration position after opening a curly bracket({ ) and press shift+ enter.
  2. Type main and select the template that inserts the main() method declaration.
  3. Similarly you can choose various templates to write then code in java.
  4. 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.
  5. Now type p, select the printLn(string X) method to write code.

Compile and execute your code:

  1. Now click on the gutter and select run “filename.main()” in the popup. The IDE starts compiling your code once compiled.
  2. 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.