Getting started with Java Programming!

In this tutorial you going to learn some basics, I’m not advanced Java programmer I only know basic comand’s. Also I will show you how to setup & start with Java. It’s really simple, but you will need to download Java, link it & download and install compiler. Java is really nice & easy programming language. It works on all Operating Systems : Windows, Mac, Linux & Solaris. When you become better Java programmer you can get job as programmer too. Like I said it’s really nice & easy programming language but in my opinion it’s best. Smile

I – Download & installing necessary drivers

First you will need to download some important drivers & applications. Well first we will need to download Java Development Kit version 6. You don’t need to worry is it infected or not because you will download from their official website. Just click link and select your Operating System. For this example I will show you for Windows OS, so you select Windows and hit Download.

[Image: 2079n55.png]

When you finish with download, just install it now we will need setup something in Control Panel. Now go to:

Control Panel > then search for System > and then Advanced system settings > click Environment Variables… click New…(Second New… button) and link your JDK bin folder. Mine is installed in C drive so link is: C:Program FilesJavajdk1.6.0_17bin and name Variable to Java.
[Image: 25fpyy0.png]
[Image: v9pbn.png]

Now you can test Java in your CMD, go to Start > Run > type in cmd > and write javac and if you get some crap about java that means you did it all good. Tongue

II – Installing Compiler ~ NetBeans

NetBeans is best compiler ever for Java. You can also use Eclipse, it’s text editor but it’s for Console only. But in NetBeans you can make Normal Desktop application, console application & website application. Cool

We will download it from their official website, so you don’t need to worry about infection. Go to this link and download it.
[Image: 2r3835s.png]

When you download it just start installation process. If you done everything correctly NetBeans will work fine.

III – NetBeans

Now you will learn more about NetBeans. There are few different types of Java applications. We are going to talk about Console Application’s and Desktop application’s.

Console Application

What’s console application?

– A console application is a computer program designed to be used via a text-only computer interface, such as a text terminal, the command line interface of some operating systems or the text-based interface included with some Graphical User Interface (GUI) operating systems.

Hello World:
To make Hello World program, you will need to make New Class. Click File > New Project… > select Java Class > click Next, name it [b]NewClass and click Finish button.

Now, we will need to make new method.

Whats method? (Click to View)
A Method provides information about, and access to, a single method on a class or interface. The reflected method may be a class method or an instance method.

A Method permits widening conversions to occur when matching the actual parameters to invokewith the underlying method’s formal parameters, but it throws an IllegalArgumentException if a narrowing conversion would occur.

So now just write this code inside your Class(NewClass):

Code:
public static void Main(String[]args){
        System.out.println("Hello, world");
    }

Desktop Application

What’s desktop application?

– Application software is computer software designed to help the user to perform a particular task. Such programs are also called software applications, applications or apps. Typical examples are word processors, spreadsheets, media players and database applications.

Hello World:
To make Hello World program, you will need to make Desktop Application. Click File > New Project… > select Java Desktop Application > click Next, name it [b]DesktopApplication1 and click Finish button.

We will need jButton1 also!

At the top of the code write:

Code:
import javax.swing.*;
import java.awt.event.*;

And now inside our method DesktopApplication1 write:

Code:
JFrame frame;
  public static void main(String[] args){
    DesktopApplication1db = new DesktopApplication1();
  }

  public DesktopApplication1(){
    frame = new JFrame("Show Message Dialog");
    JButton button = new JButton("Click Me");
    button.addActionListener(new MyAction());
    frame.add(button);
    frame.setSize(400, 400);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }

  public class MyAction implements ActionListener{
    public void actionPerformed(ActionEvent e){
      JOptionPane.showMessageDialog(frame,"Roseindia.net");
    }
  }

We will be happy to hear your thoughts

Leave a reply