Monday, February 9, 2015

Top 3 IDE's For Java Developers

1. Eclipse

Eclipse is my personal favorite IDE and I use it for my  programming, available from the year 2001 it can be considered the most widely used IDE by Java Developers.There is a huge number of plug-in's for this IDE and therefore providing wide range of options.


Follow this link to dowload eclipse free. Eclipse



2. NetBeans

Another great IDE with a truck load of features,you name it NetBeans has got it,and maybe a plus over eclipse would be the in-built GUI designer and this like eclipse is absolutely free.

Follow this link to get Netbeans free. 

3. IntelliJ







Yet another IDE used by Java Developers it offers everything the top 2 two has to offer ,a plus point in this is it comes with tools for Android and IOS Development.

Get InteliJ free from here InteliJ

Graphical User Interface Using Eclipse

Eclipse doesn't come with an in-built Graphical User Interface designer,therefore you have to download the plug-in so that you can easily design User Interfaces using Eclipse.

Installing the Plug-In

Open up eclipse and follow the following steps.

1.Select Help and then Click install new software


2. Then Select the link similar to the one in the  image and then open General Purpose Tools .
Note:The link will vary according to the version,so select the link given in the drop down list.

3.Then Tick the following and Install.

Now You can design Graphical User Interfaces without coding it,if you want to learn how to use this function wait for post on how to create a Java GUI Program.

Sunday, February 1, 2015

Setting up and Using Eclipse

First of all Eclipse is an IDE (Integrated Development Environment) it will help you develop and run programs in various programming languages.There are several more IDE's but my preferred choice is Eclipse.Therefore I will show you how to Install it and use it.

 Step 01:Downloading  Eclipse

It isn't very hard to find Eclipse online,but for those who couldn't find it you can get from here.
Choose the suitable download link after you go to this site it's on the top right of the screen.

Once you have Downloaded Eclipse all you need to do is extract the file to any destination you want and that's it you now have Eclipse.

Step 02: Working with Eclipse

First go to the Eclipse folder and then click the eclipse.exe to run eclipse.It will take some time to start and also it will ask you to choose a destination folder to store your projects you can set any destination.

Once Opened Follow these Steps to create a new class for programming using Java.

1.Create a project

You might not get Java Project at the top,if that is the case go to Other and select it from there.


Input a name for Your project and click finish.

2.Now you should see your project on the left of the screen.Drop down the project and right click on src and do the following.

3.Next fill in the class information (Only circled ones are needed)

Ticking the circled part is optional but Obviously a name must be given,once done click finish.

Now it's ready and should look like the image below and now you can start coding.The Circled Part is what we did now.







Saturday, January 31, 2015

Hello World in Java

This post will help you to write your first Java program,the function of this program is to display Hello World on your command prompt.

Open Notepad And Type The Following

Open the notepad on your PC and type in the following code, don't worry if you don't understand it I have Explained every line below.

public class HelloWorld

  public static void main(String[]args)
   {

//Prints Hello Word

  System.out.println("Hello World");
  
   }

}

Saving the File


Now save the file as HelloWorld.java,remember to change the save as type to All Files otherwise  even though you add .java to the end the file will be saved as a .txt file so don't forget to change it.
Now that you have a .java file all you need to do is run the program,if you don't know how you can check my post on How to Compile And Run a Java Program.

Explanation

Line 1 (public class HelloWorld)

This line is where the class is declared, public class are keywords in the java library and HelloWorld is the name of the class.

Line 3 (public static void main(String[]args))

This line is declaring the main method , this method is what the JVM(Java Virtual Machine) will run, anything outside of this method will not work unless it has been referenced inside this method.The Key words have Meanings, these meanings can be found from the following site.


Line 8 (  System.out.println("Hello World");)

This line is part of the code that displays Hello World on the screen, This is an in-build method in java and don't forget the semi colon at the end it is the full stop in programming.This method can be used to print any form of text or numbers on the screen.

Other parts that are not explained

1.The parenthesis

    These represent the boundary of the method and class,that means the first parenthesis is opening the class and the second is opening the method third is closing the method and fourth is closing the class.

2.Comments
  
   Anything after // symbol in a given line is not read by compiler therefore you can add any comments like this so it will explain what the program does.There are a few other ways to add comments as well,You can find these from the site I have mentioned above.

3. The blank Lines

  These lines play no part in the program but it is to increase the readability of the program.If you want the whole code may be typed in one except the comments of course,but it is not advisable. 


Important Java is a Case sensitive language therefore your code should be identical to what I have given,I advice you not to copy paste but to type the code your self it will help you remember it better.

For more Information on this you can visit http://docs.oracle.com/javase/8/

Compiling a Java Program and Running It

To Run a Java program you need to have installed Java on your system, if you don't know how you can check my post on Setting Up Java.

Step 01:Open Command prompt

Open your command prompt, for those who do not know here is a way to do it.

1. Press the Windows key + R key you will get the run window,type cmd in the window and run it.
2. Or else you open the run window from your start menu and then type cmd in the window and
    run  it.
3.  Another way is search cmd in your search bar and you will get something called command               prompt click it to open.

Now that You have opened command prompt it should look something like this.














Step 02:Set the Path

If you haven't used Java before  you will have to set the path to the Java directories so the computer knows where to look when running Java programs.
To set the path you will have to type the bold text  in the command prompt and hit Enter,(this is assuming that you have installed java with the default setting otherwise you have to enter the address where you have installed Java)

set "PATH=%PATH%;C:\Program Files\Java\jdk1.8.0_20\bin".

Step 03:Compile a Java Program

Now you have to change the directory of the command prompt to where your .java file is, for an example let's assume the .java file is in your D drive in Folder named java ex.
First type D: in the command prompt and hit enter now you will see that instead of C in the corner of the screen you will see D.

Then type cd D:\java ex and hit Enter.
Now the Command prompt window should look like this.


Now type javac fileName.java and hit Enter.
If you get the below result it means that your file has most probably compiled.The result being nothing displayed and the next line of the command prompt being displayed(file name assumed to be HelloWorld)


If you get a text saying,

'javac' is not recognized as an internal or external command,
operable program or batch file.

This means you haven't set the path correctly,go back and check it at the top of the post.

Step 04:Run A Java Program

Once you compile the .java file a .class file is formed in the same directory,
Run the program by typing the following,

java fileName

Then you should get the result below if the program is a HelloWorld program.




That's How you Compile and Run a Java Program.











Friday, January 30, 2015

Setting Up Java On Your Computer

If you are reading this blog either you know what Java is or you know who I am, For those Who don't know what Java is let me tell you that it is language used in programming.If you want to learn Java you should first install it on your computer.Let me show you how.

Step 01:Where to find Java

You need both Java Runtime Environment (JRE) and Java Development Kit(JDK) in order for you to be able to develop a program using Java, but don't worry you only need to download one file and you get both features.

The Latest Version of Java is 1.8 or just said  8.You can get  the Java setup from here

The above download will help you get the whole Java Package.

Step 02:Installing Java

 Run the setup and click on install, and follow further instructions.
















Step 03: Check if you Have Java Installed on Your Computer

Type the java -version in your command prompt window and if you have Java installed you will see a result as follows depending on the version of Java you installed.
















That's it now you have Java and you can start programming.