Create Java Project in Eclipse Neon and Setup User Library

This post shows how to create a new Java Project in Eclipse Neon and how to implement a simple HelloWorld Java class. The class can be run in Eclipse. For a step-by-step instructions on how to setup a Java SDK and install and configure Eclipse Neon for Java development, see the post:

Related Posts

1  Create New Java Project in Eclipse Neon

  • In Eclipse, use the main menu and select File > New > Project…
Eclipse Neon - Use File Menu to Create new Project
  • From the list of project wizards, select Java Project and click Next.
Eclipse Neon - Use New Project Wizard for Java Project Eclipse Neon - Use New Java Project Form to Create New Java Project in Eclipse Neon
  • Click on Finish to complete the project setup.
  • The first time a Java project is created in Eclipse, a dialog asks to open the Java perspective.
Eclipse Neon - Dialog asking to Open Associated Perspective
  • Click on Yes to continue and to open the project in the Java Perspective.
Eclipse Neon - Java Perspective and Package Explorer
  • The Java project’s source files and libraries are shown in the Package Explorer on the left hand side.
  • The Java Runtime Environment (JRE) system libraries are shown under the JRE System Library node.

2  Create New Java Class and Run it in Eclipse

  • Right-click on the Java Project node and select New > Class.
Eclipse Neon - Right-click on Java Project to Create new Class
  • On the New Java Class form, enter a package and a name for the class.
Eclipse Neon - Use New Java Class Form to Create new Class with Main Method Stub
  • The form can be used to let Eclipse create method stubs automatically, here the main method stub.
  • In the below example, code was added to iterate over a String array to print a message to the console.

public class HelloWorld {

  public static void main(String[] args) {
    // TODO Auto-generated method stub
    String[] words = new String[] {"Hello ", "World", "!"};
    for (String s : words) {
  • Run the class by clicking on the green Run icon in the tool bar and select HelloWorld.
Eclipse Neon - Run Java Class from Java Perspective and View Console Output
  • The output is shown in the Console section.

3  Setup a New User Library and it to the Build Path

  • Open the Eclipse Neon preferences and select User Libraries under Java > Build Path.
  • Click on the New… button to setup a new user library.
Eclipse Neon - Preferences - User Libraries - Empty List
  • Enter a name for the new user library, here it is JDBCDrivers, and click on OK.
Eclipse Neon - New User Library - Enter Library Name
  • Click on the button Add External JARs and select the JAR files from the file system.
Eclipse Neon - Preferences - User Libraries - Add External JARs
  • Here, 2 JDBC driver JAR files are added to allow access to PostgreSQL and MySQL databases.
Eclipse Neon - Preferences - User Libraries - List of JARs Added to Library
  • Click OK to close the User Libraries form.
  • Right-click on the project name in the Project Explorer and select Build Path > Add Libraries.
Eclipse Neon - Project Explorer - Open Project Context Menu to Add Libraries to Build Path
  • Select User Library and click on Next.
Eclipse Neon - Add Library to Build Path - Select Library Type
  • Select the User Library to add and click on Finish.
Eclipse Neon - Add Library to Build Path - Select Library to Add
  • The JAR files of the selected user library are now available on the project’s class path and its classes can be used for development. The contents of the JAR files can be viewed in the Project Explorer by expanding the JAR nodes.
Eclipse Neon - Project Explorer - View User Library JAR Contents

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.