Skip to main content

Java

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

1.3  For Ubuntu Linux

2.  Writing your First Java Program in Eclipse

Step 0: Launch Eclipse
  1. Start Eclipse by running "eclipse.exe" in the Eclipse installed directory.
  2. Choose an appropriate directory for your workspace (i.e., where you would like to save your files).
  3. 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:
  1. Choose "File" menu ⇒ "New" ⇒ "Java project".
  2. The "New Java Project" dialog pops up.
    1. In the "Project name" field, enter "FirstProject".
    2. Check "Use default location".
    3. 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.
    4. Click "Finish".
Step 2: Write a Hello-world Java Program
  1. In the "Package Explorer" (left panel) ⇒ Right-click on "FirstProject" (or use the "File" menu) ⇒ New ⇒ Class.
  2. The "New Java Class" dialog pops up.
    1. In "Name" field, enter "Hello".
    2. In "package" field, delete the content if it is not empty.
    3. Check "public static void main(String[] args)" box.
    4. Click "Finish".
  3. 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
  1. 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.
  2. To run the program, right-click anywhere on the source file "Hello.java" (or from the "Run" menu) ⇒ Choose "Run As" ⇒ "Java Application".
  3. 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.

Comments

  1. 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.
    Top Mobile App Development Company in Delhi
    Top Mobile App Development Company in Russia
    Mobile App Development Company in Europe

    ReplyDelete
  2. 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

Post a Comment

Popular posts from this blog

Multilevel inheritance

Multilevel inheritance We discussed a bit about  Multilevel inheritance  in types of inheritance in java. In this tutorial we will explain multilevel inheritance with the help of   diagram  and  example program . It’s pretty clear with the diagram that in Multilevel inheritance there is a concept of grand parent class. If we take the example of above diagram then class C inherits class B and class B inherits class A which means B is a parent class of C and A is a parent class of B. So in this case class C is implicitly inheriting the properties and method of class A along with B that’s what is called multilevel inheritance. Example : In this example we have three classes –  Car, Maruti and Maruti800. We have done a setup – class Maruti extends Car and class Maurit800 extends Maurti. With the help of this Multilevel hierarchy setup our Maurti800 class is able to use the methods of both the classes (Car and Maruti). class Car { // clas

Switch Case

Syntax : Switch Case in Java Programming It is alternative to else-if ladder. Switch Case Syntax is similar to – C/C++  Switch. Switch allows you to choose a block of statements to run from a selection of code, based on the return value of an expression. The expression used in the switch statement must return an  int, a String, or an enumerated value . switch (selection) { // value case value1 : // checking value 1 statement ( s ) ; break ; // use to break switch flow if condition match case value2 : // checking value 2 statement ( s ) ; break ; . . case value_n : statement ( s ) ; break ; default : statement ( s ) ; } Different Ways of Using Switch Case : Switch Case Using Integer Case int i=3; switch (i) { case 1 : System . out . println ( "One player is playing this game." ) ; break ; case 2 : System . out . println ( "Two players are playing

Inheritance in Java

Inheritance in Java Inheritance  is one of the feature of Object-Oriented Programming (OOPs). Inheritance allows a class to use the properties and methods of another class. In other words, the derived class inherits the states and behaviors from the base class. The derived class is also called subclass and the base class is also known as super-class . The derived class can add its own additional variables and methods. These additional variable and methods differentiates the derived class from the base class. Inheritance is a  compile-time  mechanism. A super-class can have any number of subclasses . But a subclass can have only one superclass. This is because Java does not support multiple inheritance. The superclass and subclass have  “is-a”  relationship between them. Let’s have a look at the example below. Inheritance  Example Let’s consider a superclass  Vehicle . Different vehicles have different features and properties however there few of them are common to