[Paid] ROM Toolbox Pro For Android [Apk]

[Paid] Temple Run Brave For Android [Apk]

[Paid] Camera ZOOM FX For Android [Apk]

[Paid] Poweramp Full Version Unlocker For Android [Apk]

[Paid]Full Officesuite Pro 6 + (pdf & hd) For Android [Apk]

Need for Speed™ Most Wanted For Android [Apk]

Passing data between two Screen Android[Tutorial]

Hi, today i'm going to discuss about on how we can pass parameter between two activities. before starting you need some basic knowledge on how android works and first android example .
STEP 1 :
Create New Project From Eclipse. Open main activity and write the code to get all the data from test box or any input by gettext(); method like
EditText NameRes = (EditText) findViewById(R.id.name);
String Name=NameRes.getText().toString());
STEP 2:
Now make new intent that open another activity in our case second screen.
Intent i = new Intent(getApplicationContext(), Second.class);
STEP 3:
Now put extra string that you have to pass from screen one that is in our case string name.
//i.putExtra("NEW_VARIABLE_NAME","VALUE");

i.putExtra("id","Name");
STEP 4:
Now start the activity.
StartActivity(i);
STEP 5:
Create Second.java file and catch the content from screen one by writing the code
Bundle extras = getIntent().getExtras();
if (extras != null) { String value = extras.getString("new_variable_name");
STEP 6:
Don't miss some basic configuration liike. - defining resourse in xml file. -put both the acitivity define in manifest file. that's sit. you are done. IF YOU HAVE DOUBT OR ANY QUERY LET ME KNOW.........FEEL FREE TO ASK IN COMMENT.

XCore Xperia Disable Core To Increase Battery Life


Sony xperia U is dual core processor mobile.that is CPU0 And CPU1. Sometimes there is no need to run both the core in ideal usage. second core only need to active when it required high performance like in gaming, video streaming etc.

So, this Tiny App Let Allowed Sony Xperia U User To DISABLE / ENABLE One Core To Increase Battery Performance.
---- Features ----
-Simple UI
-Optimized Battery Performance
-Easy To Use
-support CM9 also

--------ATTENTION---------
------ROOT REQUIRED-------


Setup And Creating Your First Application In Android

1.  Introduction

Android is an Operating System for mobile devices developed by Google, which is built upon Linux kernel. Android competes with Apple's iOS (for iPhone/iPad), RIM's Blackberry, Microsoft's Windows Phone (previously called Windows Mobile), Sambian OS, and many other proprietary mobile OSes.
Android Platform
Android is based on Linux with a set of native core C/C++ libraries. Android applications are written in Java. However, they run on Android's own Java Virtual Machine, called Dalvik Virtual Machine (DVM), which is optimized to operate on the mobile devices.
The mother site for Android is www.android.com. For developers, visit http://developer.android.com to download the SDK, Android Training, API Gudies and API documentation.

2.  How to Install Android SDK

NOTE: Installing all the necessary software needed for Android programming takes times - It could take hours?!
Pre-Installation Check List
Before installing Android SDK, you need to install:
  1. Java Development Kit (JDK): Read "How to install JDK".
  2. Eclipse: Read "How to install Eclipse".

Now, you are ready to install the Android SDK.
Step 0: Read the "Android Training"
Start from Android's mother site @ http://www.android.com.
Goto "Developers" @ http://developer.android.com. There are three main menus: Design, Develop, and Distribute. Start with "Develop", you can find the "Android Training", "API Guides", "Reference" and "Tools". For beginners, browse through the "Android Training".
Step 1: Download the Android SDK
Download the Android SDK from http://developer.android.com/sdk/index.html. For novices, choose the installer version by clicking the button "Download the SDK for Windows" (installer_r20-windows.exe). For Lunix and Mac, select "Other Platforms".
For advanced programmers, I recommend that you choose the ZIP version (under the "Other Platforms") (android-sdk_r20-windows.zip). I prefer the ZIP version, as you could install many versions, rename the directory, and remove the installation easily.
Read "Installing the SDK".
Step 2: Install Android SDK
Run the downloaded installer into a directory of your choice, e.g., "d:\bin\android-sdk"; or unizp the downloaded ZIP file. Take note of the installed directory. Hereafter, I shall denote the android installed directory as <ANDROID_SDK_HOME>.
Step 3: Install Android Platforms and Add-ons via "SDK Manager"
The Android SDK comprises 2 parts: the "tools" and the "Platforms & Add-ons". After running the installer (in the pervious step), the basic "tools" are installed, which are executables that support app development. The "Platforms & Add-ons" consist of ALL Android platforms (from Android 1.x to 4.x) and various Google Add-ons (such as Google Map API), which could be selectively installed.
Now, we have to choose our Android "Platforms & Add-ons".
  1. Launch Android's "SDK Manager", which is responsible for managing the software components. If you have run the installer, it should have started the SDK Manager after the installation. Otherwise, launch the SDK manager by running (double-clicking) "SDK Manager.exe" under the Android installed directory.
  2. In "Add Platforms and Packages", select your target Android platforms and add-ons packages. For novices, select "Android SDK Platform-Tools", and at least one Android platform (e.g., Android 4.1 (API 16)) ⇒ "Install".
Step 4: Install Eclipse Android Development Tool (ADT) Plugin
I suppose that you have installed Eclipse.
  1. Launch Eclipse.
  2. Install Eclipse ADT: From Eclipse's "Help" menu ⇒ "Install New Software..." ⇒ In "Work with", enter https://dl-ssl.google.com/android/eclipse/ ⇒ Check ALL boxes ⇒ Next ⇒ Finish ⇒ Restart Eclipse to use ADT plugin.
  3. Configure Eclipse ADT: From Eclipse's "Window" menu ⇒ Preferences ⇒ Android ⇒ In "SDK Location", select the Android SDK installed directory (e.g., "d:\bin\android-sdk").
Step 5: Create a Android Virtual Device (AVD) (or Emulator) via "AVD Manager"
AVDs are emulators that allow you to test your application without the real devices. You can create AVDs for different android platforms (from Android 1.x to Android 4.x) and configurations (e.g., screen size, orientation, SD card and its capacity).
  1. From Eclipse's "Window" menu ⇒ Preferences ⇒ Android ⇒ In "SDK Location", enter your Android SDK installed directory (e.g., "d:\bin\android-sdk").
  2. From "Window" menu ⇒ AVD Manager. (You could also start the AVD manager by running "AVD Manager.exe" under the Android SDK installed directory.)
  3. In "Android Virtual Device Manager" dialog ⇒ "New".
  4. The "Create New Android Virtual Device (AVD)" dialog appears. In "Name", enter "Android41_Phone". Select the "Target" Android platform, "SD Card Size" (e.g., 10MB, do not set a huge SD Card size, which would take hours to create.) Skin (screen resolution, e.g., WVGA800x480 for smart phone - Wiki "Graphics display resolution" for the various resolution) ⇒ "Create AVD".
You can test your AVD by launching the emulator. Start the AVD manager ⇒ Select a AVD ⇒ Click the "Start" button ⇒ Check "Scale display to real size" to get a smaller screen that could fit in your display ⇒ Launch. Wait patiently! The emulator is very slow and take a few MINUTES to launch. You can change the orientation (between portrait and landscape) of the the emulator via "Ctrl-F11".
We typically create different AVDs to emulate different real devices, e.g., Android41_tablet of resolution (1024x768 XGA).
Step 6: Setup PATH
You can skip this step now if you are not familiar with PATH, but it is needed later.
Include the android's tools directory (<ANDROID_SDK_HOME>\tools) and platform-tools directory (<ANDROID_SDK_HOME>\platform-tools) to your PATH environment variable.
For Windows: Start "Control Panel" ⇒ "System" ⇒ (Vista/7) "Advanced system settings" ⇒ Switch to "Advanced" tab ⇒ "Environment variables" ⇒ Choose "System Variables" for all users (or "User Variables" for this login user only) ⇒ Select variable "PATH" ⇒ Choose "Edit" for modifying an existing variable ⇒ In variable "Value", APPEND your <ANDROID_SDK_HOME>\tools directory (e.g., "d:\bin\android-sdk\tools"), followed by a semi-colon ';', IN FRONT of all the existing path entries. DO NOT remove any existing entry; otherwise, some programs may not run.
Add the platform-tools directory to the PATH too.

3.  Write your First Android Program Using Eclipse ADT

Android apps are written in Java, and use XML extensively. I shall assume that you have basic knowledge of Java programming and XML.

3.1  Hello-world

Step 0: Read
Go to "Android Training" @ http://developer.android.com/training/index.html, Read "Get Started", "Build your first app".
Step 1: Create a new Android Project
  1. Launch Eclipse.
  2. From "File" menu ⇒ New ⇒ Project.. ⇒ Android Application Project ⇒ Next.
  3. The "New Android Project" dialog appears:
    1. In "Application Name", enter "Hello Android" (this is the Android appliation name that shows up on the real device).
    2. In "Project Name", enter "HelloAndroid" (this is the Eclipse's project name).
    3. In "Package Name", enter "com.example.helloandroid".
    4. In "Build SDK", select the latest version (e.g., Android 4.1 (API 16)).
    5. In "Minimum Required SDK", select "API 8 Android 2.2 (Froyo)" - almost all of the Android devices meet this minimum requirement ⇒ Next.
  4. The "Configure Launcher Icon" dialog appears, which allows you to set the application's icon to be displayed on the devices ⇒ Next.
  5. The "Create Activitiy" dialog appears. Check "Create Activity" Box ⇒ Select "BlankActivity" ⇒ Next.
  6. The "New Blank Activity" dialog appears.
    1. In "Activity Name", enter "HelloActivity".
    2. In "Layout Name", enter "activity_hello" (default).
    3. In "Title", enter "Hello" (this title will appear as the screen title) ⇒ Finish.
Eclipse ADT creates a default Hello-world Android app.
Step 2: Run the Android App
Run the application by right-click on the project node ⇒ "Run As" ⇒ "Android Application".
Be patient! It takes a few MINUTES to fire up the emulator! Watch the Eclipse's status bar for the launching progress; and the console view (or LogCat view) for messages.
Once the emulator started, unlock the device by holding and sweeping the "lock" to the right (or left). It shall launch your Hello-world app, and displays "Hello, world!" on the screen with a title "Hello".
If your program is not launched automatically, try launching it from the "app menu" manually, after the emulator is started. Look for the icon "Hello".
Trying launching the app from "HOME" ⇒ "..." ⇒ Look for the icon "Hello".
Also try "HOME" ⇒ "..." ⇒ "MENU" ⇒ "Manage Apps" ⇒ Select "HelloAndroid" ⇒ Uninstall.
NOTE: DO NOT CLOSE the emulator, as it really takes a long time to start. You could always re-run or run new applications on the same emulator.
Run the Android App on Real Devices
To run the Andriod app on the real devices:
  1. Connect the real device to your computer. Make sure that you have the "USB Driver" for your device installed on your computer. You can find the "Google USB Driver" @ http://developer.android.com/sdk/win-usb.html, and Google's certified "OEM USB Drivers" @ http://developer.android.com/tools/extras/oem-usb.html. If you device is not certified there, good luck! It took me many hours to find a compatible driver for my cheap Pad.
  2. Enable "USB Debugging" mode on your real device: from "Settings" ⇒ "Applications" ⇒ "Development" ⇒ Check "USB Debugging". This allows Android SDK to transfer data between your computer and your device.
    Also enable "Unknown source" from "Applications". This allows applications from unknown sources to be installed on the device.
  3. You shall see the message "USB Debugging Connected" when you plugs the USB cable into your computer.
  4. From Eclipse, right-click on the project node ⇒ Run As ⇒ Android Application.
  5. The "Android Device Chooser" dialog appears. Select your real device (instead of the AVD emulator) ⇒ OK.
  6. Eclipse ADT installs the app on the connected device and starts it.
You can also use the "adb" (Android Debug Bridge) tool (under "<ANDROID_SDK_HOME>\platform-tools") to install the ".apk" file ("HelloAndroid.apk") onto the real devices:
// Change directory to <project-root>\bin, where the ".apk" is located
// -d option for real device

> adb -d install filename.apk
2402 KB/s (157468 bytes in 0.064s)
pkg: /data/local/tmp/filename.apk
Success

> adb --help

3.2  Hello-world by Coding

Let's continue from the previous example.
Expand the "src" node. Expand the "com.example.helloandroid" package node. Open the "HelloActivity.java", and replace it with the following codes:
package com.example.helloandroid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView textView = new TextView(this); // Construct a TextView UI component
textView.setText("Hello, from my code!"); // Set the text message for TextView
setContentView(textView); // this Activity sets its content to the TextView
}
}
Run the application by right-clicking the project node ⇒ "Run As" ⇒ "Android Application". You shall see the message "Hello, from my code!".
Dissecting the "HelloActivity.java" - Application, Activity & View
An application could have one or more Activity.
An Activity, which usually has a screen, is a single, focused thing that the user can interact with the applicatoin. The HelloActivity extends the android.app.Activity class, and overrides the onCreate() method. The onCreate() is a call-back method, which will be called by the Android system when the activity is launched.
A View is a UI component (or widget, or control). We construct a TextView (which is a subclass of android.view.View), and set its text message. We then set the content-view of the HelloActivity screen to this TextView.
Android Application Structure
The Android project (under Eclipse ADT) consists of several folders:
  • src: Java Source codes. The Java classes must be kept in a proper package with at least two levels of identifiers (e.g., com.example).
  • res: Resources, including drawable (e.g., images and icons), layout (UI components and layout), values (e.g., locale strings for internationalization).
  • asset: where you store raw files (e.g., configuration, audio and image files).
  • gen: Generated Java codes.
  • bin: Compiled bytecodes (in sub-directory classes), and the ".apk" (Android Package Archive file).
  • AndroidManifest.xml: The manifest to describe this app, such as its activities and services.
  • default.properties: holds various settings for the build system, updated by the ADT.
  • Android 4.1: the build target platform, with link to Android API ("android.jar").
Android Application Descriptor File - "AndroidManifest.xml"
Each Android application has a manifest file named AndroidManifest.xml in the project's root directory. It descibes the application.
For example, our "HelloAndroid" application, with an activity HelloActivity, has the following manifest (generated automatically by the Eclipse ADT):

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloandroid"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".HelloActivity"
android:label="@string/title_activity_hello" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

  • The <manifest> element specifies the package name, version-code and version-name. The version-code is an integer uses by the Android Market to keep track of new version, usually starts at 1. The version-name is a string for your own identification. It is interesting and confusing that two elements are used to identify a version, e.g., Android platform 4.1 has API Level 16.
  • The <manifest> contains one <application> element.
  • The <application> element specifies the icon, label (the application's title) and theme of this application. It contains one ore more <activity> elements.
  • This application has one activity named HelloAndroid. The <activity> element declares its program name (".HelloActivity" where '.' is relative to the package com.example.helloandroid, you can also use fully-qualified name); and label (the activity's screen title). It may contain <intent-filter>.
  • The <intent-filter> declares that this activity is the entry point (android.intent.action.MAIN) of the application. This activity is to be added to the application launcher (android.intent.category.LAUNCHER).

3.3  Hello-world using XML Layout

Instead of writing program codes to create the UI. It is more flexible and recommended to layout your UI components via a descriptive XML layout file. In this way, you don't need to hardcode the views, and you can easily modify the look and feel of the application by editing the XML markups. The programming codes can therefore focus on the business logic. (This is similar to the Model-View-Control (MVC) framework used in web applications where the views are written in JSPs using markups and the controls in Servlets, which are clearly separated. This is also similar to client-side programming where HTML is used for contents, CSS for presentation and JavaScript for programming logic. Again, views, contents and programs are clearly separated).
To improve the performance, the XML files are compiled into binary using the Android Asset Packaging Tool (aapt). The devices store them as binary, and the file is read in binary, instead of converting back to XML.
Let's rewrite our hello-world to use XML layout.
Step 1: Create a New Android Application
Create a new Android project called "HelloAndroidXML". Use "HelloAndroidXML" for the application name and project name, "com.example.helloandroidxml" for package name. Create a "BlankActivity" called "HelloActivity", with layout name "activity_hello" and title "HelloXML".
Step 2: Define the Layout in XML - "res\layout\activity_hello.xml"
Expand the "HelloAndroidXML" project node. Expand the "res" node and "layout" node. Open the "activity_hello.xml". Eclipse provides different views for a XML file: Graphics Layout and XML. Select the "activity_hello.xml" tab (at the bottom of the panel) and study the code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/hello_world"
tools:context=".HelloActivity" />
</RelativeLayout>
The activity_hello.xml file declares a TextView that holds a text string. Instead of hardcoding the string content, a string reference called @string/hello_world is used, with the actual string coded in res/values/strings.xml. This approach is particular useful to support internationalization, as you can customize different strings for different locales.
This activity's uses a "relative layout", where its components are arranged relative to each other. It has width and height matching its parent ("match_parent").
The screen contains a TextView component, with its text obtained from the string reference "@string/hello_world". The TextView component has width and height big enough to hold its content ("wrap_content"), and is centralized horizontally and vertically.
Step 3: Defining String References and Values - "res\values\string.xml"
Expand res/values node. Open strings.xml, and study the code:
<resources>
<string name="app_name">HelloAndroidXml</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_main">HelloXML</string>
</resources>
This "string.xml" defines these string references and values:
  • The string reference "hello_world" contains string value of "Hello world!". Change it to "Hello, from XML!".
  • The string reference "app_name" contains the application's name, that you entered when you created the project. This reference is used in "AndroidManifest.xml".
  • The string reference "title_activity_main" contains the activity's title. This reference is also used in "AndroidManifest.xml". Change it to "Hello in XML Layout"
Step 4: The Activity - "HelloActivity.java"
Next, study the "HelloActitivy.java" (right-click on the project ⇒ Expand "src" node ⇒ Expand package node "com.example.helloandriodxml"), as follows:
package com.example.helloandroidxml;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class HelloActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hello);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_hello, menu);
return true;
}
}
The "HelloActivity" sets its content-view to "R.layout.activity_hello", which is mapped to the XML layout file "res\layout\activity_hello.xml" that we have studied earlier.
Step 5: Run the App
Run the application (select "Run As" menu ⇒ "Android Application"). You shall see the new string "Hello, from XML!" and new title "Hello in XML Layout" displayed on the emulator.
Step 6: The Generated Resource Reference Class - "gen\R.java"
The Eclipse ADT automatically generates a "R.java", which keeps track of all the application resources, in "gen" directory as follows:
package com.example.helloandroidxml;

public final class R {
public static final class attr {
}
public static final class dimen {
public static final int padding_large=0x7f040002;
public static final int padding_medium=0x7f040001;
public static final int padding_small=0x7f040000;
}
public static final class drawable {
public static final int ic_action_search=0x7f020000;
public static final int ic_launcher=0x7f020001;
}
public static final class id {
public static final int menu_settings=0x7f080000;
}
public static final class layout {
public static final int activity_hello=0x7f030000;
}
public static final class menu {
public static final int activity_hello=0x7f070000;
}
public static final class string {
public static final int app_name=0x7f050000;
public static final int hello_world=0x7f050001;
public static final int menu_settings=0x7f050002;
public static final int title_activity_hello=0x7f050003;
}
public static final class style {
public static final int AppTheme=0x7f060000;
}
}
The R.java ("R" stands for resources) indexes all the resources used in this application in the static nested classes such as layout and string. For example, the inner class layout's property activity_hello (R.layout.activity_hello) references res\layout\activity_hello.xml; the inner class string references res\values\strings.xml.

4.  Publishing Your App

To publish your apps on Android Maket/Google Play, you need to sign your app with your digital certificate. (During development, you app is signed using a debug certificate by the Eclipse ADT.)
Signing Android Apps
  1. From Eclipse, right-click on the project ⇒ Export... ⇒ Android ⇒ Export Android Application.
  2. In "Project Checks" dialog ⇒ Next.
  3. In "Keystore selection" ⇒ Create new keystore ⇒ In "Location", enter the filename for the keystore (e.g., keystore.db) ⇒ Set your password for the keystore.
  4. In "Key creation", enter the data ⇒ Finish.
References:
  1. Signing Your Applications @ http://developer.android.com/tools/publishing/app-signing.html.
  2. For keystore management, read JDK documentation on "keytool - Key and Certificate Management Tool".

5.  Using Android Debug Bridge (ADB)

ADB lets you manage the connected real devices and emulator AVDs. ADB actually consists of three parts:
  • A client program called "adb.exe" (kept under the "<ANDROID_SDK_HOME>\platform-tools").
  • A server that that runs on your development machine, which is responsible for communicating between an "adb" client program and the connected real devices or emulator AVDs.
  • The ADB daemon, which runs as a background process on every real device and emulator AVD. The ADB server connects to this daemon for communication.
You can use the "adb" client to install Android apps (in ".apk" format), or copy files between your development machine and real device's internal storage and external SD card.
From a CMD shell, launch the "adb" client program (you need to include the "<ANDROID_SDK_HOME>\platform-tools" in PATH environment variable):
// List the command options
> adb --help
......

// List all the devices connected, take note of the device serial number
> adb devices
......

// Install app in the device of the given serial number
> adb –s device_id install app_filename.apk
// Install app on real device
> adb -d install app_filename.apk
// Install app on emulator
> adb -e install app_filename.apk

// Copy the file from the development machine to the device
> adb push computer_filename sdcard_filename
// Copy the file from the device to development machine
> adb pull sdcard_filename computer_filename

6.  Next?

Continue with the "Android Training" @ http://developer.android.com/training/index.html.
Read the Android "API Guides" @ http://developer.android.com/guide/components/index.html.
Study the Android sample codes (in Android SDK "samples" directory), especially the "API Demos".
To run the sample programs in Eclipse: Select "File" menu ⇒ "New" ⇒ "Project..." ⇒ "Android" ⇒ "Android Sample Project" ⇒ E.g., "API Demos".
To import an existing project:
  1. Select "File" menu ⇒ "New" ⇒ "Project..." ⇒ "Android" ⇒ "Android Project from Existing Code" ⇒ Next.
  2. In "Import Project" dialog, browse and select the desired project from the Android SDK's "samples" (e.g., "ApiDemos"). Check "Copy projects into workspace".
  3. Run the application. Right-click on the project ⇒ "Run As" ⇒ "Android Application".
REFERENCES & RESOURCES
  1. Android SDK @ http://developer.android.com/sdk/index.html.
  2. "Android Training" @ http://developer.android.com/training/index.html.
  3. Android "API Guides" @ http://developer.android.com/guide/components/index.html.

Installing JDK 7 in Windows [Tutorials]

Java Development Kit (JDK) 1.7 (officially named Java SE 7), which is freely available from Sun Microsystems (now part of Oracle), is needed for writing Java programs. JDK can be downloaded from the Java mother site @ http://java.sun.com (or http://www.oracle.com/technetwork/java/index.html).
JDK or JRE?
JRE (Java Runtime) is needed for running Java programs. JDK (Java Development Kit), which includes JRE plus the development tools (such as compiler and debugger), is need for writing Java programs. Since you are supposed to write Java Programs, you should install JDK, which includes JRE.
JDK Versions
The various JDK versions are:
  1. JDK Alpha and Beta (1995): Sun announced Java in September 23, 1995.
  2. JDK 1.0 (January 23, 1996): Originally called Oak (named after the oak tree outside James Gosling's office). Renamed to Java 1 in JDK 1.0.2.
  3. JDK 1.1 (February 19, 1997): Introduced AWT event model, inner class, JavaBean, JDBC, and RMI.
  4. J2SE 1.2 (codename Playground) (December 8, 1998): Rebranded as "Java 2" and renamed JDK to J2SE (Java 2 Standard Edition). Also released J2EE (Java 2 Enterprise Edition) and J2ME (Java 2 Micro Edition). Included JFC (Java Foundation Classes - Swing, Accessibility API, Java 2D, Pluggable Look and Feel and Drag and Drop). Introduced Collection Framework and JIT compiler.
  5. J2SE 1.3 (codename Kestrel) (May 8, 2000): Introduced Hotspot JVM.
  6. J2SE 1.4 (codename Merlin) (February 6, 2002): Introduced assert, non-blocking IO (nio), logging API, image IO, Java webstart, regular expression support.
  7. J2SE 5.0 (codename Tiger) (September 30, 2004): Officially called 5.0 instead of 1.5. Introduced generics, autoboxing/unboxing, annotation, enum, varargs, for-each loop, static import.
  8. Java SE 6 (codename Mustang) (December 11, 2006): Renamed J2SE to Java SE (Java Standard Edition).
  9. Java SE 7 (codename Dolphin) (July 28, 2011): First version after Oracle purchased Sun (called Orcale JDK).
  10. Java SE 8: expected in summer 2013.

1.  How To Install JDK (on Windows)

Step 0(a): Un-Install Older Version(s) of JDK/JRE
I always recommend to install the latest JDK, but it can be messy if you have multiple versions of JDK/JRE.
If you have previously installed older version(s) of JDK/JRE, un-install ALL of them. Run "Control Panel" ⇒ Program and Features ⇒ Un-install programs begin with "Java", such as "Java SE Development Kit" and "Java SE Runtime". If you are not sure whether you have older version(s) of JDK, check!
Step 0(b): Understand Windows' CMD Shell

Step 1: Download JDK
  1. Goto Java SE download site @ http://www.oracle.com/technetwork/java/javase/downloads/index.html.
  2. Click the "Download" button under "JDK" of "Java SE 7".
  3. Choose your operating platform, e.g., Windows x86 for 32-bit Windows OS or Windows x64 for 64-bit Windows OS - You can check whether your OS is 32-bit or 64-bit via "Control Panel" ⇒ System ⇒ Under the "System Type".
Step 2: Install JDK and JRE
Run the downloaded installer (e.g., "jdk-7uxx-windows-i586.exe"), which installs both the JDK (Java Development Kit) and JRE (Java Runtime). By default, the JDK will be installed in directory "C:\Program Files\java\jdk1.7.0_{xx}", where {xx} denotes the latest upgrade number; and JRE in "C:\Program Files\java\jre7".
For novices, accept the defaults. Simply click "next"..."next"... to install JDK in "C:\Program Files\java\jdk1.7.0_{xx}" and JRE in "C:\Program Files\java\jre7". Take note of you JDK installed directory. I shall refer to the JDK installed directory as <JAVA_HOME>, hereafter, in this article.
(For Advanced Users Only) The default JDK/JRE directories work but I recommend avoiding "Program Files" directory because of that blank character in the directory name. You may change the installed directories for JDK and JRE during installation. I personally installed JDK and all my programming tools in "d:\bin" (instead of "C:\Program Files") for ease of maintenance.
Step 3: Include JDK's "bin" Directory in the PATH
Windows OS searches the current directory and the directories listed in the PATH environment variable for executable programs. JDK's programs (such as Java compiler javac.exe and Java runtime java.exe) reside in directory "<JAVA_HOME>\bin" (where <JAVA_HOME> denotes the JDK installed directory, e.g., C:\Program Files\java\jdk1.7.0_{xx}). You need to include the "<JAVA_HOME>\bin" directory in the PATH.
To edit the PATH environment variable in Windows 2000/XP/Vista/7:
  1. "Start" button ⇒ "Control Panel" ⇒ "System" ⇒ (Vista/7 only) "Advanced system settings".
  2. Switch to "Advanced" tab ⇒ "Environment Variables..."
  3. In "System Variables" box, scroll down to select "PATH" ⇒ "Edit..."
  4. (Caution: Read thru the paragraph carefully before performing this step!) In "Variable value" field, INSERT "c:\Program Files\java\jdk1.7.0_{xx}\bin" (VERIFY that this is your JDK's binary directory) IN FRONT of all the existing directories, followed by a semi-colon (;) which separates the JDK's binary directory from the rest of the existing directories. DO NOT DELETE any existing entries; otherwise, some existing applications may not run.
    Variable name  : PATH
    Variable value : c:\Program Files\java\jdk1.7.0_{xx}\bin;....exiting entries....
(For Advanced Users Only)
I suggested that you place the JDK bin directory in front of "c:\windows\system32" and "c:\windows". This is because some Windows systems may have an out-dated copy of JDK/JRE in these directories. Do a search for "java.exe", and you will be amazed of the findings.
You could read "Java Applications and Environment Variable" for more discussions about PATH environment variable.
I also recommend that you define an environment variable called JAVA_HOME, which contains the JDK installed directory, and include the JDK bin directory in the PATH via JAVA_HOME, i.e., PATH=%JAVA_HOME%\bin;.....
Step 4: Verify the JDK Installation
Launch a CMD shell ("Start" button ⇒ run... ⇒ enter "cmd"; or "Start" button ⇒ All Programs ⇒ Accessories ⇒ Command Prompt).
  1. Issue a "path" command to list the content of the PATH environment variable. Check the output and make sure that <JAVA_HOME>\bin is listed in the PATH.
    prompt> path
    PATH=c:\Program Files\java\jdk1.7.0_{xx}\bin;......other entries......
  2. Issue the following commands to verify that JDK is properly installed and display its version:
    prompt> java -version
    java version "1.7.0_{xx}"
    Java(TM) SE Runtime Environment (build 1.7.0_{xx}-b11)
    Java HotSpot(TM) Client VM (build 23.3-b01, mixed mode, sharing)

    prompt> javac -version
    javac 1.7.0_{xx}
Step 5: Write a Hello-World Java Program
  1. Create a directory to keep all your works, e.g., d:\myproject, or any directory of your choice. Do NOT save your works in "Desktop" or "My Documents" as they are hard to locate. The directory name shall not contain blank or special characters. Use meaningful but short name as it is easier to type.
  2. Launch a programming text editor (such as TextPad or NotePad++ or NotePad if you have no better choice). Begin with a new file and enter the following source code. Save the file as "Hello.java", under your work directory (e.g., d:\myproject).
    /*
    * First Java program to say Hello
    */

    public class Hello { // saved as "Hello.java" under "d:\myproject"
    public static void main(String[] args) {
    System.out.println("Hello, world!");
    }
    }
Step 6: Compile and Run the Hello-World Java Program

  1. To compile the source code "Hello.java":
    1. Start a CMD Shell ("Start" button ⇒ Select "run..." ⇒ Enter "cmd"; or "Start" button ⇒ All Programs ⇒ Accessories ⇒ Command Prompt).
    2. Set the Current Drive to the drive where you saved your source file "Hello.java". For example, suppose that your source file is saved in drive "d", enter "d:" as follow:
      prompt> d:
      D:\xxx>
    3. Set the Current Working Directory to the directory that you saved your source file via the cd (Change Directory) command. For example, suppose that your source file is saved in directory "d:\myproject".
      D:\xxx> cd \myproject
      D:\myproject>
    4. Issue a dir (List Directory) command to confirm that your source file is present in the current directory.
      D:\myproject> dir
      ......
      08-May-XX 06:25 PM 277 Hello.java
      ......
    5. Invoke the JDK compiler "javac" to compile the source code "Hello.java".
      D:\myproject> javac Hello.java
      The compilation is successful if the command prompt returns. Otherwise, error messages would be shown. Correct the errors in your source file and re-compile. if you encounter problems compiling your program.
    6. The output of the compilation is a Java class called "Hello.class". Issue a dir (List Directory) command again to check for the output.
      D:\myproject> dir
      ......
      03-Jul-xx 01:53 PM 416 Hello.class
      08-May-xx 06:25 PM 277 Hello.java
      ......
  2. To run the program, invoke the Java Runtime "java":
    D:\myproject> java Hello
    Hello, world!

Step 7: (Optional) Download JDK API Documentation, Samples and Demos
The JDK download does not include the documentation, which needs to be downloaded separately. In the past, I always insist that my students should have a local copy of JDK API Documentation. But, today, you can easily access the online copy by googling "JDK 7 Documentation".
To install JDK API documentation:
  1. From the Java SE download page (@ http://www.oracle.com/technetwork/java/javase/downloads/index.html), look for "Java SE 7 Documentation" (under "Additional Resources") ⇒ Download the zip-file (e.g., "jdk-7....zip" - about 57MB).
  2. Unzip into the <JAVA_HOME> (JDK installed directory). The documentation will be unzipped into "<$JAVA_HOME>\docs". Browse the JDK documentation by opening "<JAVA_HOME>\docs\index.html".
You should also download the "JDK Samples and Demos" from the Java SE download site.
Step 8: (For Advanced Users Only) JDK's Source Code
Source code for JDK is provided and kept in "<JAVA_HOME>\src.zip". I strongly recommend that you to go through some of the source files such as "String.java", "Math.java", and "Integer.java", under "java\lang".

4.  (Advanced) External JAR Files and Native Libraries

External Java packages (such as Servlet, MySQL Connector/J, JOGL, JUnit) are often distributed in JAR files (Java Archive - a single-file package of many Java classes), with possibly Native Libraries (".lib" and ".dll" in Windows, or ".a" and ".so" in Linux/Mac).
External JAR Files (".jar")
If external JAR files are not properly included:
  • During the compilation, you will receive compilation error "cannot find symbol" on classes belonging to the external packages.
  • During executation, you will get a runtime error "Error: Could not find or load main class xxx",
To include external JAR files, you can either:
  1. Copy all the JAR files of the external packages to the JDK's Extension Directories.
    • For Windows, the JDK extension directory is located at "<JAVA_HOME>\jre\lib\ext" (e.g., "c:\Program Files\java\jdk1.7.0_{xx}\jre\lib\ext").
    • For Mac, the JDK extension directories are "/Library/Java/Extensions" and "/System/Library/Java/Extensions".
    • For Ubuntu, the JDK extension directories are "<JAVA_HOME>/jre/lib/ext" (e.g., "/usr/lib/jvm/jdk1.7.0_{xx}/jre/lib/ext") and "/usr/java/packages/lib/ext".
    The location of JDK's extension directories is kept in Java's System Property "java.ext.dirs". You can print its contents via System.out.println(System.getProperty("java.ext.dirs")).
  2. You can include all the JAR files in the CLASSPATH environment variable. The CLASSPATH may contain directories (containing Java classes) or JAR files (single-file archive of Java classes). If you set the CLASSPATH, you must also include the current directory (denoted as ".").
    • For Windows, set the CLASSPATH in Control Panel ⇒ System ⇒ Advanced system settings ⇒ Advanced ⇒ Environment Variables ⇒ System Variables ⇒ New ⇒ In "Variable name", enter "CLASSPATH" ⇒ In "Variable value", enter ".;path1\xxx.jar;path2\yyy.jar", where the entries are separated by a semi-colon (;).
    • For Linux and Mac OS: Edit ~/.profile or ~/.bash_profile to include the following line at the end of the file:
      export CLASSPATH=.:path1/xxx.jar:path2/yyy.jar
      The entries are seperated by colon (:).
  3. You can also set the CLASSPATH in the javac/java's command-line via the option -cp <paths> (or -classpath <paths>), for example,
    // Compile Java source code
    > javac -cp .:path1/xxx.jar:path2/yyy.jar ClassName.java
    // Run Java class
    > java -cp .:path1/xxx.jar:path2/yyy.jar ClassName
External Native Libraries (".lib", ".dll", ".a", ".so")
Some external package may provide static or shared native libraries in the form of ".lib" (Windows' static library), ".dll" (Windows' dynamically link library), ".a" (Unix's static library), or ".so" (Unix's shared library).
Native Libraries are to be kept in a directory accessible via JRE's Property "java.library.path", which normally but not necessarily includes all the directories from the PATH environment variable.
Native libraries are not involved in the compilation. But if they are not properly included during runtime time, you will get a runtime error "java.lang.UnsatisfiedLinkError: no xxx in java.library.path".
To include external native libraries:
  1. Copy the native libraries into a system library directory, e.g., c:\windows\system32 (Windows), /usr/lib or /usr/local/lib (Linux or Mac OS). You can verify that the directory is included in System Property "java.library.path", via System.out.println(System.getProperty("java.library.path")).
  2. You can also set the native library path via the java's command-line option -Djava.library.path=xxx, for example,
    > java -Djava.library.path=xxx ClassName

Installing Eclipse For Android Programming [Tutorial]

Eclipse (@ www.eclipse.org) is an open-source Integrated Development Environment (IDE) supported by IBM. Eclipse is popular for Java application development (Java SE and Java EE) and Android apps. It also supports C/C++, PHP, Python, Perl, and other web project developments via extensible plug-ins. Eclipse is cross-platform and runs under Windows, Lunix and Mac OS.
Eclipse Versions
The various versions are:
  • Eclipse 1.0 (November 7, 2001): based on an earlier Java IDE called VisualAge from IBM.
  • Eclipse 2.0 (June 28, 2002)
  • Eclipse 2.1 (March 28, 2003)
  • Eclipse 3.0 (June 25, 2004)
  • Eclipse 3.1 (June 28, 2005)
  • Eclipse 3.2 (June 30, 2006) (Callisto - named after one of the Jupiter's Galilean moons): started annual simultaneous release of all the related Eclipse projects.
  • Eclipse 3.3 (June 25, 2007) (Europa - named after another Jupiter's Galilean moons)
  • Eclipse 3.4 (June 19, 2008) (Ganymede - named after yet another Jupiter's Galilean moons)
  • Eclipse 3.5 (June 12, 2009) (Galileo - named after the great 17th century scientist and astronomer Galileo Galilei)
  • Eclipse 3.6 (June 23, 2010) (Helios - named after god of the sun in Greek Mythology)
  • Eclipse 3.7 (June 23, 2011) (Indigo)
  • Eclipse 4.2 (June 27, 2012) (Juno)

1.  How to Install Eclipse 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). Read "How to Install JDK (on Windows)".
Step 1: Download
Download Eclipse from http://www.eclipse.org/downloads. For beginners, choose the minimal Eclipse IDE for "Java" Developers (e.g., "eclipse-java-juno-win32.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.

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. Check "public static void main(String[] args)" box.
    3. 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.

3.  Read the Documentation

At a minimum, you SHOULD browse through Eclipse's "Workbench User Guide" and "Java Development User Guide" - accessible via the Eclipse's "Welcome" page or "Help" menu. This will save you many agonizing hours trying to figure out how to do somethings later.

4.  Debugging Programs in Eclipse

Able to use a graphics debugger to debug program is crucial in programming. It could save you countless hours guessing on what went wrong.
Step 0: Write a Java Program
The following program computes and prints the factorial of n (=1*2*3*...*n). The program, however, has a logical error and produce a wrong answer for n=20 ("The Factorial of 20 is -2102132736" - a negative number?!).

/** Compute the Factorial of n, where n=20.
* n! = 1*2*3*...*n
*/

public class Factorial {
public static void main(String[] args) {
int n = 20; // To compute factorial of n
int factorial = 1; // Init the product to 1

int i = 1;
while (i <= n) {
factorial = factorial * i;
i++;
}
System.out.println("The Factorial of " + n + " is " + factorial);
}
}
Let's use the graphic debugger to debug the program.
Step 1: Set an Initial Breakpoint
A breakpoint suspends program execution for you to examine the internal states (e.g., value of variables) of the program. Before starting the debugger, you need to set at least one breakpoint to suspend the execution inside the program. Set a breakpoint at main() method by double-clicking on the left-margin of the line containing main(). A blue circle appears in the left-margin indicating a breakpoint is set at that line.
Step 2: Start Debugger
Right click anywhere on the source code (or from the "Run" menu) ⇒ "Debug As" ⇒ "Java Application" ⇒ choose "Yes" to switch into "Debug" perspective (A perspective is a particular arrangement of panels to suits a certain development task such as editing or debugging). The program begins execution but suspends its operation at the breakpoint, i.e., the main() method.
As illustrated in the following diagram, the highlighted line (also pointed to by a blue arrow) indicates the statement to be executed in the next step.
Step 3: Step-Over and Watch the Variables and Outputs
Click the "Step Over" button (or select "Step Over" from "Run" menu) to single-step thru your program. At each of the step, examine the value of the variables (in the "Variable" panel) and the outputs produced by your program (in the "Console" Panel), if any. You can also place your cursor at any variable to inspect the content of the variable.
Single-stepping thru the program and watching the values of internal variables and the outputs produced is the ultimate mean in debugging programs - because it is exactly how the computer runs your program!
Step 4: Breakpoint, Run-To-Line, Resume and Terminate
As mentioned, a breakpoint suspends program execution and let you examine the internal states of the program. To set a breakpoint on a particular statement, double-click the left-margin of that line (or select "Toggle Breakpoint" from "Run" menu).
"Resume" continues the program execution, up to the next breakpoint, or till the end of the program.
"Single-step" thru a loop with a large count is time-consuming. You could set a breakpoint at the statement immediately outside the loop (e.g., Line 11 of the above program), and issue "Resume" to complete the loop.
Alternatively, you can place the cursor on a particular statement, and issue "Run-To-Line" from the "Run" menu to continue execution up to the line.
"Terminate" ends the debugging session. Always terminate your current debugging session using "Terminate" or "Resume" till the end of the program.
Step 5: Switching Back to Java perspective
Click the "Java" perspective icon on the upper-right corner to switch back to the "Java" perspective for further programming (or "Window" menu ⇒ Open Perspective ⇒ Java).
Important: I can's stress more that mastering the use of debugger is crucial in programming. Explore the features provided by the debuggers.
Other Debugger's Features
Modify the Value of a Variable: You can modify the value of a variable by entering a new value in the "Variable" panel. This is handy for temporarily modifying the behavior of a program, without changing the source code.
Step-Into and Step-Return: To debug a method, you need to use "Step-Into" to step into the first statement of the method. ("Step-Over" runs the function in a single step without stepping through the statements within the function.) You could use "Step-Return" to return back to the caller, anywhere within the method. Alternatively, you could set a breakpoint inside a method.

5.  Tips & Tricks

5.1  General Usages (for all Programming Tasks)

These are the features that I find to be most useful in Eclipse:
  1. Maximizing Window (Double-Clicking): You can double-click on the "header" of any panel to maximize that particular panel, and double-click again to restore it back. This feature is particularly useful for writing source code in full panel.
  2. Shorthand Templates (sysout, for,...): You can type "sysout" followed by a ctrl+space (or alt-/) as a shorthand for typing "System.out.println()".
    The default shortcut key (ctrl-space or alt-/) depends on the system. Check your system's shortcut key setting in "Edit" ⇒ "Content Assist" ⇒ "Default". Take note that many of you use ctrl+space to switch between input languages. You need to reconfigure either your language switching hot-key or Eclipse.
    Similarly, you can type "for" followed by ctrl-space (or alt-/) to get a for-loop.
    You can create your own shorthand in "Window" menu ⇒ "Preferences" ⇒ "Java" ⇒ "Editor" ⇒ "Templates". (Alternatively, in "Window" ⇒ "Preferences" ⇒ type "template" as filter text and choose "Java" ⇒ "Editor" ⇒ "Templates".)
    You can change your key settings in "Window" menu ⇒ "Preferences" ⇒ "General" ⇒ "Key" ⇒ choose "Command", "Content Assist". (Alternatively, in "Window" ⇒ "Preferences" ⇒ type "key" as filter text and choose "General" ⇒ "Key".)
  3. Intelli-Sense (ctrl-space): You can use ctrl-space to activate the "intelli-sense" (or content assist). That is, Eclipse will offer you the choices, while you are typing.
  4. Source Formatting (ctrl-shift-f): Right-click on the source. Choose "Source" ⇒ "Format" to let Eclipse to layout your source codes with the proper indentation.
  5. Source Toggle Comment (ctrl-/): To comment/uncomment a block of codes, choose "Source" ⇒ "Toggle Comment".
  6. Hints for Correcting Syntax Error: If there is a syntax error on a statement, a red mark will show up on the left-margin on that statement. You could click on the "light bulb" to display the error message, and also select from the available hints for correcting that syntax error.
  7. Refactor (or Rename) (alt-shift-r): You can rename a variable, method, class, package or even the project easily in Eclipse. Select and right-click on the entity to be renamed ⇒ "Refactor" ⇒ "Rename". Eclipse can rename all the occurrences of the entity.
  8. Line Numbers: To show the line numbers, choose "Window" menu ⇒ "Preferences" ⇒ "General" ⇒ "Editors" ⇒ "Text Editors" ⇒ Check the "Show Line Numbers" Box. You can also configure many editor options, such as the number of spaces for tab. Alternatively, you can right-click on the left-margin, and check "Show Line Numbers".
  9. Error Message Hyperlink: Click on an error message will hyperlink to the corresponding source statement.
  10. Changing Font Type and Size: From "Window" menu ⇒ "Preferences" ⇒ "General" ⇒ "Appearance" ⇒ "Colors and Fonts" ⇒ expand "Java" ⇒ "Java Editor Text Font" ⇒ "Edit". (Alternatively, in "Window" ⇒ "Preferences" ⇒ type "font" as filter text and choose the appropriate entry.)
  11. Unicode Support: To enable Unicode support, select "Window" menu ⇒ Preferences ⇒ General ⇒ Workspace ⇒ Text file encoding ⇒ UTF-8. This sets the default character set used for file encoding, similar to VM's command-line option -Dfile.encoding=UTF-8. Commonly used charsets for Unicode are UTF-8, UTF-16 (with BOM), UTF-16BE, UTF-16LE. Other charsets are US-ASCII, ISO-8859-1.
  12. Mouse Hover-over: In debug mode, you could configure to show the variable's value when the mouse hovers over the variable. Select "Window" menu ⇒ "Preferences" ⇒ "Java" ⇒ "Editor" ⇒ "Hover".
  13. Comparing Two Files: In "Package Explorer", select two files (hold the control key) ⇒ Right-click ⇒ Compare with.
  14. Useful Eclipse Shortcut Keys:
    • F3: Goto the declaration of the highlighted variable/method.
    • Ctrl-Shift-G: Search for ALL references of the highlighted variable/method in workspace.
    • Ctrl-G: Search for the Declaration of a variable/method in workspace.
      Don't use Find (Ctrl-F), but use the above context-sensitive search.
    • Ctrl-Shift-F: Format the source code.
    • Ctrl-Shift-O: Organize imports.
    • Alt-Shift-R: Rename. (Don't use Find/Replace.)
    • Ctrl-Space: auto-complete.
  15. Package Explorer vs. Naviagator: We usually use "Package Explorer" in programming, but it will not show you all the folders and files under the project. On the other hand, "Navigator" is a file manager that shows the exact file structure of the project (similar to Windows Explorer). You can enable the Navigator by "Window" ⇒ Show view ⇒ Navigator.
  16. Let me know if you have more tips to be included here.

5.2  For Java Application Development Only

  1. Eclipse 3.7 does not support JDK 7. Eclipse 4.2 does.
  2. Small Toy Java Programs: You can keep many small programs (with main()) in one Java project instead of create a new project for each toy program. To run the desired program, right-click on the source file ⇒ "Run as" ⇒ "Java Application".
  3. Scanner/printf() and JDK 1.5: If you encounter syntax error in using printf() or Scanner (which are available from JDK 1.5), you need to check your compiler settings. Select "Window" menu ⇒ Preferences ⇒ open the "Java" node ⇒ select "Compiler" ⇒ in "Compiler compliance level" ⇒ select the latest release, which should be "1.5" or above.
  4. Command-Line Arguments: To provide command-line arguments to your Java program in Eclipse, right-click on the source file ⇒ "Run Configurations" ⇒ Under the "Main" panel, check that "Project" name and "Main Class" are appropriate ⇒ Select the "Argument" tab ⇒ type your command-line arguments inside the "Program Arguments" box ⇒ "Run".
  5. Resolving Import (Ctrl-Shift-o): To ask Eclipse to insert the import statements for classes. Useful when you copy a large chunk of codes without the corresponding import statements.
  6. Including Another Project: To include another project in the same work space, right-click on the project ⇒ Build Path ⇒ Configure Build Path... ⇒ Select "Projects" tab ⇒ "Add..." to select project in the existing work space ⇒ OK.
  7. Exporting a Project to a JAR file: Right-click on the project ⇒ Export... ⇒ Java, JAR File ⇒ Next ⇒ Select the files to be exported ⇒ Next ⇒ Next ⇒ In "JAR Manifest Specification" dialog, enter the main class (if you wish to run the JAR file directly) ⇒ Finish.
  8. Unit Testing: If you keep your test in another project, you need to include the project under test in your Build Path (see above).
    To create a test case: Right-click on the project ⇒ New ⇒ JUnit Test Case ⇒ the "New JUnit Test Case" dialog appears. Select "New JUnit 4 Test". In "Name", enter your class name. In "Class under test", browse and select the class to be tested.
    To run the test: Right-click ⇒ "Run As" ⇒ "JUnit Test". The results are displayed in a special "JUnit console".
  9. Adding External JAR files & Native Libraries (".dll", ".lib", ".a", ".so"): Many external Java packages (such as JOGL, Java3D, JAMA, etc) are available to extend the functions of JDK. These packages typically provide a "lib" directory containing JAR files (".jar") (Java Archive - a single-file package of Java classes) and native libraries (".dll", ".lib" for windows, ".a", ".so" for Lunix and Mac).
    To include these external packages into an Eclipse's project, right-click on the project ⇒ Build Path ⇒ Add External Archives ⇒ Navigate to select the JAR files (".jar") to be included.
    In "Package Explorer", right-click on the JAR file added ⇒ Properties:
    • To include native libraries (".dll", ".lib", ".a", ".so"), select "Native Library" ⇒ "Location Path" ⇒ "External Folder".
    • To include the javadoc, select "JavaDoc Location" ⇒ "JavaDoc URL" ⇒ You can specify a local file or a remote link.
    • To include source file (for debugging), select "Java Source Attachment".
    All the above options are also accessible via project's property ⇒ "Build Path".
    Notes: The JAR files must be included in the CLASSPATH. The native library directories must be included in JRE's property "java.library.path", which normally but not necessarily includes all the paths from the PATH environment variable. Read "External JAR files and Native Libraries".
  10. Creating a User Library: You can also create a Eclipse's user library to include a set of JAR files and native libraries, that can then be added into subsequent Eclipse projects.
    For example, I created a user library for "JOGL" as follows:
    1. From "Window" menu ⇒ Preferences ⇒ Java ⇒ Build Path ⇒ User Libraries ⇒ New ⇒ In "User library name", enter "jogl". The "User Library" dialog appears.
    2. In "User Library" dialog ⇒ Select "jogl" ⇒ Add JAR... ⇒ Navigate to <JOGL_HOME>/lib, and select "gluegen-rt.jar" and "jogl.jar".
    3. Expand the "jogl.jar" node ⇒ Select "Native library location: (none)" ⇒ Edit... ⇒ External Folder... ⇒ select <JOGL_HOME>/lib.
    4. Expand the "jogl.jar" node ⇒ Select "Javadoc location: (none)" ⇒ Edit... ⇒ Javadoc in archive ⇒ In "Archive Path", "Browse" and select the downloaded JOGL API documentation zip-file ⇒ In "Path within archive", "Browse" and expand the zip-file to select the top-level path (if any) ⇒ Validate. Alternatively, you can provide the path to the un-zipped javadocs. This is needed for Eclipse to display javadoc information about classes, fields, and methods.
    5. You may provide the source files by editing "Source attachment: (none)". Source is needed only if you are interested to debug into the JOGL source codes.
    For EACH subsequent Java project created that uses JOGL, right-click on the project ⇒ Build Path ⇒ Add Libraries ⇒ Select "User Library" ⇒ Check "jogl".
  11. Running an External Program: Suppose that you want to run a Perl script on the selected file, you can configure an external tool as follows:
    1. From "Run" menu ⇒ External Tools ⇒ External Tools Configuration... ⇒ The "External Tools Configuration" dialog appears.
    2. In "Name", enter your tool name.
    3. Choose the "Main" tab ⇒ In "Location", "Browse File System..." to choose the perl interpreter "perl" ⇒ In "Arguments", enter "path/scriptname.pl ${resource_loc}", where ${resource_loc} is an Eclipse variable that denotes the currently selected resource with absolute path.
    4. Choose the "Common" tab ⇒ In "Standard Input and Output", uncheck "Allocate Console", check "File" and provide an output file (e.g., d:\temp\${resource_name}.txt).
    5. (If you use the CYGWIN perl interpreter, need to set environment variable CYGWIN=nodosfilewarning to disable warning message.)
    To run the configured external tool, select a file ⇒ run ⇒ external tool ⇒ tool name.
  12. Viewing Hex Code of Primitive Variables in Debug mode: In debug perspective, "Variable" panel ⇒ Select the "menu" (inverted triangle) ⇒ Java ⇒ Java Preferences... ⇒ Primitive Display Options ⇒ Check "Display hexadecimal values (byte, short, char, int, long)".
  13. Adding a New Version of JDK/JRE: First, you can check the installed JDK/JRE via "Window" menu ⇒ "Preferences" ⇒ Expand "Java" node ⇒ "Installed JREs". Check the "Location" current JRE installed to make sure that it is the intended one. You can use the "Add" button to add a new version of JRE. For program development, I recommend that you add the JDK (instead of JRE). [The "Location" decides the extension directory used for including additional JAR files, e.g., $JAVA_HOME\jre\lib\ext.]

6.   File I/O in Eclipse

Suppose that your want to write a Java program, which inputs from a text file called "xxxx.in" and outputs to a text file called "xxxx.out". This is a little tricky under Eclipse due to:
  1. When you create a text file in Windows' Notepad and saved it as "xxxx.in", Notepad will append the ".txt" to your file and it becomes "xxxx.in.txt". Worse still, the Windows' Explorer, by default, will not show the ".txt" extension. (The first thing I always do to an alien computer is to change this setting. From "Tools" menu ⇒ Folder Options... ⇒ View ⇒ Uncheck "Hide extensions for known file types".) You need to put a pair of double quotes around xxxx.in to override the default ".txt" extension. This is one good reason not to use Notepad for programming at all. You should use Eclipse to create the text file instead.
  2. Which directory to keep the input file "xxxx.in" in Eclipse?
    • If you did not separate the sources and class files into two separate directories, then the answer is straight forward, because there is only one directory to place your input file.
    • If you choose to keep your sources and class files in two separate directories, eclipse will create two sub-directories "src" and "bin" under the base directory. BUT you need to put your input file "xxxx.in" in the base directory of your project, instead of the "src" or "bin"..
For writing simple programs:
  • Put the sources, class files, and the input/output files in the same directory. (When you create a new project, select "Use project folder as root for sources and class files" in "Project Layout".) (But put your sources and class files in separate directories for big project.)
  • You can create you input file from eclipse directly via "File" menu ⇒ "New" ⇒ "File".
  • Remember to add a newline to the end of your input file.
  • You may need to right-click the project and select "Refresh" to see the output file "xxxx.out" created in the package explorer.
  • To open the "xxxx.in" and "xxxx.out": right-click ⇒ Open With ⇒ Text Editor.
This is a sample JDK 1.5 program for file input/output:
import java.util.Scanner;
import java.util.Formatter;
import java.io.File;
import java.io.IOException;

public class FileIOTest { // saved as "FileIOTest.java"
public static void main (String [] args) throws IOException {
Scanner in = new Scanner(new File("FileIOTest.in")); // file input
Formatter out = new Formatter(new File("FileIOTest.out")); // file output

int a = in.nextInt();
int b = in.nextInt();
out.format("%d\n",a+b); // format() has the same syntax as printf()

out.close(); // flush the output and close the output file
}
}
Create the input text file called "FileIOTest.in" with the following contents and terminated with a newline:
55 66 

7.  Writing Swing Application using Eclipse GUI Builder

These codes are written in Eclipse 3.7.2. Between Eclipse and Netbeans, Netbeans GUI builder for Swing Application is more versatile and powerful. Read "Writing Java GUI (AWT/Swing) Application in NetBeans". However, Eclipse supports many windowing toolkits other than Swing, such as SWT (Standard Widget Toolkit - an alternative to AWT/Swing for Java program), XWT, GWT, eRCT.
Step 1: Create a New "Java Application" Project
  1. Choose "File" menu ⇒ "New" ⇒ "Java project".
  2. The "New Java Project" dialog pops up.
    1. In the "Project name" field, enter "FirstSwingProject".
    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: Create a Swing JFrame Subclass
  1. Choose "File" menu ⇒ "New" ⇒ "Other..." ⇒ "WindowBuilder" ⇒ "Swing Designer" ⇒ "JFrame" ⇒ "Next".
  2. In the "Create JFrame" dialog ⇒ Enter "FirstSwingProgram" in the "Name" field ⇒ "Finish".
  3. Select the "Design" pane.
  4. In "Layouts", select "FlowLayout" and click on the "design form".
  5. From "Components", select "JLabel" and click on the desing form. Change the label text to "Counter: ". Select a "JTextField" and place it on the design form. Change the text to "0". Select a "JButton" and place it on the design form. Change the text label to "Count".
  6. To attach a event-handler to the button, double-click the JButton to switch into the "Source" pane, with the event-handler skeleton created. Complet the actionPerformed() as follows:
    public void actionPerformed(ActionEvent e) {
    count++;
    textField.setText(count + "");

    }
    Add an instance variable called count as follow:
    public class FirstSwingProgram extends JFrame {
    private int count = 0;
    ......
  7. You can now ready run the program.
Eclipse Generated Codes
Study the codes generated by Eclipse GUI Builder, as follows, which is just a typical Swing application.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;

public class FirstSwingProgram extends JFrame { // A JFrame application

// Define private variables of all the GUI components
private JPanel contentPane;
private JTextField textField;
private int count = 0;

/**
* Launch the application.
*/

public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() { // same as SwingUtilities.invokeLater()
@Override
public void run() {
try {
FirstSwingProgram frame = new FirstSwingProgram();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/

public FirstSwingProgram() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

JLabel lblNewLabel = new JLabel("Counter: ");
contentPane.add(lblNewLabel);

textField = new JTextField();
textField.setText("0");
contentPane.add(textField);
textField.setColumns(10);

JButton btnCount = new JButton("Count");
btnCount.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
count++;
textField.setText(count + "");
}
});
contentPane.add(btnCount);
}
}

8.  Eclipse PDT (PHP Developer Tool)

Eclipse PDT is an IDE for PHP program development. The main advantage is it can debug PHP programs with XDebug or Zend Debugger.
The mother site for Eclipse PDT is http://www.eclipse.org/pdt. Read the "Downloads" and "Installation" documents.
Alternative PHP IDEs are: NetBeans (@ http://www.netbeans.org), PHPEclipse (@ http://www.phpeclipse.com).

8.1  Installing Eclipse PDT

  1. If you have never installed any Eclipse package, goto Eclipse mother site @ http://www.eclipse.org ⇒ Downloads ⇒ Select "Eclipse for PHP Developers". Download and unzip the donwloaded file.
  2. If you have installed an Eclipse package (such as Eclipse IDE for Java Developers):
    1. Launched Eclipse ⇒ Select menu "Help" ⇒ "Install New Software"
    2. The "Install" dialog appears. In "Work with" field, enter "http://download.eclipse.org/releases/juno" (for Eclipse 4.2) or "http://download.eclipse.org/releases/helios/" (for Eclipse 3.7).
    3. In "Name" box, expand "Programming Language" node ⇒ Check "PHP Development Tools (PDT) SDK Features" ⇒ "Next" ⇒ ... ⇒ "Finish".
  3. You need to configuring Eclipse to support PHP development. Launch Elcipse ⇒ Select menu "Window" ⇒ "Preferences" ⇒ Expand "PHP" node:
    1. Select "PHP Servers" ⇒ Check that there is an entry with "Name" of "Default PHP Server" and "URL" "http://localhost".
    2. Select "PHP Executable" ⇒ "Add" ⇒ In "Name", Enter a name, e.g. "WampServer". In "Executable Path", enter the location of PHP executable "php.exe". For WampServer, it shall be "<WAMPSERVER_HOME>\bin\php\php5.x.x\php.exe". In "PHP ini file", enter the php configuration file used by the WampServer, e.g., "<WAMPSERVER_HOME>\bin\apache\Apache2.2.xx\bin\php.ini". In "PHP Debugger", select "XDebug", which is bundled in WampServer.
    3. Select "Debug" ⇒ In "PHP Debugger", select "XDebug". In "Server", select "Default PHP Server". In "PHP Executable", select the PHP Executable configured in the previous step, i.e., "WampServer".
    4. Select "PHP Manual" ⇒ Check that there is an entry with "Site Name" of "php.net" with "URL" of "http://www.php.net/manual/en".
    5. Browse through other settings for PHP.

8.2  Writing a Hello-world PHP program in Eclipse PDT

  1. Launch Eclipse with a workspace.
  2. Create a new project: "File" ⇒ "New" ⇒ "PHP Project". In "Project Name", enter a name for the project, e.g., "hello". In "Contents", select "Create project at exiting location", enter your web server's root directory followed by the project name, e.g., d:\WampServer\www\hello. ⇒ "Finish".
  3. Write your PHP program: Right-click on the project "hello" ⇒ "New" ⇒ "PHP File". Enter the following codes and saved as "HelloObj.php":
    <?php
    class Hello{
    // Variables
    var $message;

    // Constructor
    function __construct(){
    $this->message= "Hello World!";
    }

    /**
    * Function that prints the value of the instance variable $message
    */

    function printMessage(){
    echo $this->message;
    }
    }
    ?>
    Again, create a new PHP file for the following driver program "HelloDriver.php":
    <?php
    include_once('HelloObj.php');
    $hello= new hello();
    $hello->printMessage();
    ?>
  4. To run the program, right-click anywhere on "HelloDriver.php" ⇒ "Run As" ⇒ "PHP Script" (output shown in console) or "PHP Web Page" (output shown in Eclipse internal browser or external browser).

8.3  Debugging PHP Script in Eclipse PDT

To use XDebug under Eclipse PDT, change "xdebug.remote_enable = on" in the "pdp.ini", and restart the server.
To debug the program, right-click anywhere on "HelloDriver.php" ⇒ "Debug As" ⇒ "PHP Script" or "PHP Web Page". You can step thru the program, inspect the variables, set break point, etc. (See "Eclipse HowTo" on how to debug program under Eclipse.)
If you check "Break at First Line", the program will pause at every first line of the php file. You need to "Resume" or "Step Over".

9.  Eclipse and Database Development (MySQL)

Reference: "Data Tools Platform User Documentation" @ Eclipse Welcome page.
You need to install Eclipse for Java EE, MySQL and MySQL Connector/J Driver. Read "How to install and get started with MySQL".
To use Eclipse for MySQL development:
  1. Switch to "Database Development" perspective: From "Window" menu ⇒ Open Prespective ⇒ Other ⇒ Database Development.
  2. Connect to MySQL database server: Start your MySQL database server. Right-click "Database Connection" ⇒ New.
    1. In "Connection Profile", choose "MySQL" ⇒ Next.
    2. In "Driver", choose "New Driver Definition" ⇒ Choose the MySQL Connector/J Driver ⇒ In JAR List, select the MySQL Connector/J Driver JAR file (that you have installed). In "Properties", "General", specify URL (take note of the database name), User name and password ⇒ Test Connection ⇒ Finish.
    3. In "Datasource Explorer", you can "connect" and "disconnect" the connection.
  3. To create a new SQL script, choose File ⇒ New ⇒ SQL File ⇒ You may use an existing project or create a new project (General - Project or Web - Dynamic Web Project) ⇒ Enter filename, and set the connection profile name ⇒ Finish. Enter a SQL statement (e.g., SELECT * FROM tablename) ⇒ Right-click on the text ⇒ "Execute Current Text" or "Execute All".
  4. To use an existing SQL file, drop the file into a project and open the SQL file. In Connection profile, set the type and connection name. Right-click on a statement ⇒ "Execute ...".
  5. To CURD (create-update-read-delete) tables, in "Datasource Explorer" (of the "Database Development" perspective), expand "database" to view the tables. Right-right on the table ⇒ Datat ⇒ Edit.

10.  Developing and Deploying Web Applications in Eclipse for Java EE

10.1  Setting Up Eclipse for Web Development

  1. Install "Eclipse for Java EE (Enterprise Edition)".
  2. Install Tomcat (or Glassfish) server.
  3. Configuring Web Server: Launch Eclipse ⇒ Window ⇒ Preferences ⇒ Expand the "Server" node ⇒ "Runtime Environments" ⇒ "Add..." ⇒ Expand "Apache" and select "Apache Tomcat v7.0" ⇒ Enter the "Tomcat Installation Directory" ⇒ "Finish".

10.2  Writing a Hello-world JSP Page

  1. Create a new Web Application: File ⇒ New ⇒ Dynamic Web Project (under "Web" category) ⇒ In "Project Name", enter "HelloJSP" ⇒ Finish.
  2. Create a new JSP File: Right-click on the project "HelloJSP" ⇒ New ⇒ JSP File ⇒ The parent folder shall be "HelloJSP/WebContent" ⇒ In "File Name", enter "Hello" ⇒ "Finsih".
  3. Enter the following HTML/JSP codes within the <body>...</body> tags:
    <h1>Hello World!</h1>
    <%
    out.println("Your IP address is " + request.getRemoteAddr() + "<br/>");
    out.println("Your user agent is " + request.getHeader("user-agent") + "<br/>");
    %>
  4. To execute the JSP, right-click on "Hello.jsp" ⇒ Run As ⇒ Run on Server.

10.3  Writing a Hello-world Servlet

  1. Create a new Web Application: File ⇒ New ⇒ Dynamic Web Project (under "Web" category) ⇒ In "Project Name", enter "HelloServlet" ⇒ "Finish".
  2. Create a new Servlet: Right-click on the project "HelloServlet" ⇒ New ⇒ Servlet ⇒ In "Java Package", enter "hello"; in "Class Name", enter "HelloServlet" ⇒ Next ⇒ In "URL Mappings", select "\HelloServlet", "Edit" to "\Hello" ⇒ Next ⇒ In "Which method stubs would you like to create", check "Inherited abstract method" and "doGet" ⇒ Finish.
    In "HelloServlet.java", enter the following codes:
    package hello;

    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.annotation.WebServlet;

    @WebServlet("/sayhello") // URL for this Servlet (for Servlet 3.0 with Tomcat 7)
    public class HelloServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    // Set the response message MIME type (in Content-Type response header)
    response.setContentType("text/html");
    // Get an output Writer to write the response message over the network
    PrintWriter out = response.getWriter();
    // Write the response message (in an HTML page) to display "Hello, world!"
    out.println("<!DOCTYPE html>");
    out.println("<html><head>");
    out.println("<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>");
    out.println("<title>Hello Servlet</title></head>");
    out.println("<body><h1>Hello, World!</h1>");
    out.println("<p>Your IP address is " + request.getRemoteAddr() + "</p>");
    out.println("<p>Your user agent is " + request.getHeader("user-agent") + "</p>");
    out.println("</body></html>");
    }
    }
    (For Servlet 2.4/2.5 with Tomcat 6) The annotation @WebServlet is new in Servlet 3.0 and is not supported in Servlet 2.4/2.5. Hence, you need to manually configure the URL for the servlet in the Web Application Deployment Descriptor "web.xml" under directory "WEB-INF", as follows:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0" metadata-complete="true">

    <servlet>
    <servlet-name>HelloServletExample</servlet-name>
    <servlet-class>hello.HelloServlet</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>HelloServletExample</servlet-name>
    <url-pattern>/sayhello</url-pattern>
    </servlet-mapping>

    </web-app>
  3. To execute the Servlet, right-click on the "HelloServlet" project ⇒ "Run As" ⇒ "Run on Server" ⇒ Change the URL to "http://localhost:8080/HelloServlet/sayhello".

10.4  Exporting a Web Application as a WAR file

Right-click on the project to be exported ⇒ Export ⇒ WAR File ⇒ In "Destination", specify the destination directory and filename (the filename shall be the web application name) ⇒ Finish.
  1. To deploy the war file in Tomcat, simply drop the war file into Tomcat's "webapps" folder. The war file will be automatically extracted and deployed. The web application name is the war-filename.
  2. You could use WinZip (or WinRAR) to view the content of the war file, as war-file is in ZIP format.

10.5  Writing a Hello-world JSF Page

[TODO]

10.6  Debugging Web Applications

You can debug a webapp just like standalone application. For example, you can set breakpoints, single-step through the programs, etc.
REFERENCES & RESOURCES
  1. Eclipse mother site @ www.eclipse.org.
  2. Eclipse documentation and user guides, accessible via Eclipse's Help and menu.

 
TheMobiForest - Ultimate Forest Of Technology © 2012-2014 | Designed by Cheap TVS, in collaboration with Vegan Breakfast, Royalty Free Images and Live Cricket Score