Welcome
How to Install Eclipse 4.5 (Mars) for Java
1.1 For Windows
Step 0: Install JDK
To use Eclipse for Java programming, you need to first install Java Development Kit (JDK). From https://eclipse.org/downloads/
Step 1: Download
Download Eclipse from http://www.eclipse.org/downloads. For beginners, choose "Eclipse IDE for Java Developers" (32-bit or 64-bit) (e.g., "
eclipse-java-mars-SR1a-win32-x86_64.zip
").Step 2: Unzip
To install Eclipse, simply unzip the downloaded file into a directory of your choice (e.g., "
d:\myproject
").
There is no need to run any installer. Moreover, you can simply delete the entire Eclipse directory when it is no longer needed (without running any un-installer). You are free to move or rename the directory. You can install (unzip) multiple copies of Eclipse in the same machine.
1.2 For Macs
Read "How to Install Eclipse on Mac".
1.3 For Ubuntu Linux
Read "How to Install Eclipse on Ubuntu".
2. Writing your First Java Program in Eclipse
Step 0: Launch Eclipse
- Start Eclipse by running "
eclipse.exe
" in the Eclipse installed directory. - Choose an appropriate directory for your workspace (i.e., where you would like to save your files).
- If the "Welcome" screen shows up, close it by clicking the "close" button.
Step 1: Create a new Java Project
For each Java application, you need to create a project to keep all the source files, classes and relevant resources.
To create a new Java project:
- Choose "File" menu ⇒ "New" ⇒ "Java project".
- The "New Java Project" dialog pops up.
- In the "Project name" field, enter "
FirstProject
". - Check "Use default location".
- In the "JRE" box, select "Use default JRE (currently 'JDK1.x')". But check the JDK version, you should be using JDK 1.5 and above.
- Click "Finish".
- In the "Project name" field, enter "
Step 2: Write a Hello-world Java Program
- In the "Package Explorer" (left panel) ⇒ Right-click on "
FirstProject
" (or use the "File" menu) ⇒ New ⇒ Class. - The "New Java Class" dialog pops up.
- In "Name" field, enter "
Hello
". - In "package" field, delete the content if it is not empty.
- Check "
public static void main(String[] args)
" box. - Click "Finish".
- In "Name" field, enter "
- The source file "
Hello.java
" opens on the editor panel. Enter the following codes:public class Hello { // "Hello.java" public static void main(String[] args) { System.out.println("Hello, world!"); } }
Step 3: Compile & Execute the Java Program
- There is no need to compile the Java source file explicitly. It is because Eclipse performs the so-called incremental compilation, i.e., the Java statement is compiled as and when it is entered.
- To run the program, right-click anywhere on the source file "
Hello.java
" (or from the "Run" menu) ⇒ Choose "Run As" ⇒ "Java Application". - The output "Hello, world!" appears on the "Console" panel.
NOTES:
- You should create a new Java project for each of your Java application.
- Nonetheless, Eclipse allows you to keep more than one programs in a project, which is handy for writing toy programs (such as your tutorial exercises). If you have more than one files with
main()
method in one project, you need to right-click the source and choose "Run As" ⇒ "Java Application" to run that particular source. Clicking the "Run" button runs the recently-run program (based on the previous configuration). Try clicking on the "down-arrow" besides the "Run" button.
As a leading Top Mobile App Development Company, Appsinvo company is well known to design and build customized web and mobile app solutions for the clients. Complete integration of the mobile app and the website gives the businesses a boost not only in their growth but also in the revenue.
ReplyDeleteTop Mobile App Development Company in Delhi
Top Mobile App Development Company in Russia
Mobile App Development Company in Europe
Great information...I am happy to find this post Very Helpful for me, as it contains lot of information. Are you looking for a company which provide best java app development services than not to worry. CodersNews listed Top 15 Java App Development Companies. Their Java app development solutions uniquely tailored to your business needs.
ReplyDelete