How to Run Java Program with Eclipse

From Java Example Source Code

Jump to: navigation, search

[edit] Overview

This article describes how to create Java program and run it in the Eclipse.

Many java programmers find it easier to build programs in Eclipse, an environment designed explicitly for editing, running, and testing programs.

Eclipse has been implemented for all three major operating systems (Microsoft Windows, Unix variants, including Linux, and Macintosh OS X).

Eclipse is powerful, fairly easy to use, and it is free.

This article is free; you can redistribute it and/or modify it. However, Publications based on this article must include an appropriate reference to http://java.exampleshow.com.

[edit] Prepare Environment for Java Program

To write your first program and run it with Eclipse, you'll need:

[edit] Run Java Program in Eclipse

To start Eclipse, find the Eclipse folder, double click eclipse.exe.

  • Select a Workspace. During the startup, Eclipse asks you to specify the location of the workspace - where Eclipse will store your Java programs. Use C:\exampleshow\workspace as shown below:

Image:SelectWorkspace.PNG

  • Eclipse IDE shows up on the screen. Sometimes, Eclipse starts with a tutorial window. If it does, you should close that window.
  • Create new Java Project from the menu File - New - Java Project, and a window shows up as show below.

Image:NewJavaProject.PNG

  • Create new Java Class from the menu File - New - Class. Input the name of Java class as show below.

Image:NewJavaClass.PNG

  • Write your java code.
  • To run your program, click the Run Icon, or select menu Run - Run as - Java application, you will see the result in the Console window as show below.

Image:Result.PNG

Personal tools