Why Learn Java

59
views
Why Learn Java
(Last Updated On: October 21, 2018)

Lets first understand why learn Java what are it’s benefits and how Java will help in the growth of your carrier.

What is Java

Java technology is both a programming language and a platform.
Java – As a Programming Language

The Java programming language is a high-level, object-oriented and general-purpose computer programming language.

Java is similar to C++ but simplified to eliminate language features that cause common programming errors.

You can use Java to write computer applications that play games, store data or do any of the thousands of other things computer software can do.

It is intended to let application developers “write once, run anywhere” (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation.

Java – As a Computing Platform

A platform is the hardware or software environment in which a program runs. Some of the most popular platforms are Microsoft Windows, Linux, Solaris OS, and Mac OS.

Since Java has its own runtime environment (JRE) and API, it is called a platform.

There are lots of applications and websites that will not work unless you have Java installed, and more are created every day. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!

Where is Java used?

According to Sun, 3 billion devices run Java. There are many devices where Java is currently used. Some of them are as follows:

  • Desktop Applications such as Acrobat reader, media player, antivirus etc.
  • Web Applications such as irctc.co.in, javatpoint.com etc.
  • Enterprise Applications such as banking applications.
  • Mobile
  • Embedded System
  • Smart Card
  • Robotics
  • Games etc.

History of Java

Java was developed by Sun Microsystems in the early-to-mid 1990s, and development continues to this day, of course. Here are some of the more important milestones in the early history of the language:

1990: A team headed by James Gosling is set up to work on a programming language for consumer electronic devices. The goals were to develop a small language, that would easily adapt to new chips, and be very reliable. The language was originally known as Oak, but that name was already used, so it had to be changed.

1992: The team creates a project called Star 7 (*7), and develops a personal, hand-held remote control. The development team is incorporated as FirstPerson, Inc., but loses a bid to develop a TV set-top box for Time-Warner.

1994: The team notices the popularity of the web, which came along in 1993, and builds a first web-enabled browser, WebRunner. Sun executives are impressed.

May 23, 1995: At Sun World in San Francisco Sun Microsystems, Inc., formally announces Java 1.0, and Netscape also announces it will license Java for its browser.

1995—present: The rest of the world notices, programmers go bananas, and the rest, as they say, is history …

For Detail History of JAVA Click here.

Features Of Java

There is given many features of Java. They are also known as Java buzzwords.

Features of Java Programming Language are:

  • Simple:
    Java is Easy to write and more readable and eye-catching.
    Java has a concise, cohesive set of features that make it easy to learn and use.
    Most of the concepts are drawn from C++ thus making Java learning simpler.
  • Secure:
    Java program cannot harm other systems thus making it secure.
    Java provides a secure means of creating Internet applications.
    Java provides a secure way to access web applications.
  • Portable:
    Java programs can execute in any environment for which there is a Java run-time system.(JVM)
    Java programs can be run on any platform (Linux, Windows, Mac)
    Java programs can be transferred over world wide web (e.g applets)
  • Object-oriented:
    Java programming is an object-oriented programming language.
    Like C++ Java provides most of the object-oriented features.
    Java is pure OOP. Language. (while C++ is semi object-oriented)
  • Robust:
    Java encourages error-free programming by being strictly typed and performing run-time checks.
  • Multithreaded:
    Java provides integrated support for multithreaded programming.
  • Architecture-neutral:
    Java is not tied to a specific machine or operating system architecture.
    Machine Independent i.e Java is independent of hardware .
  • Interpreted:
    Java supports cross-platform code through the use of Java bytecode.
    Bytecode can be interpreted on any platform by JVM.
  • High performance:
    Bytecodes are highly optimised.
    JVM can be executed them much faster.
  • Distributed:
    Java was designed with the distributed environment.
    Java can be transmitted, run over the internet.
  • Dynamic:
    Java programs carry with them substantial amounts of run-time type information that is used to verify and resolve accesses to objects at runtime.
    Here is Graphical Representation why learn Java
why learn Java
Graphical Representation why learn Java

Java Installation

You need to download java-based on your operating system.
You can download Java from Here.

There are various editions of Java:

Java SE stands for Java standard edition and is normally for developing desktop applications, forms the core/base API.

Java EE stands for Java Enterprise Edition for applications which run on servers, for example, websites.

Java ME stands for Java Micro-edition for applications which run on resource-constrained devices (small-scale devices) like cell phones, for example, games.

Further, every Java edition consists of two elements: JRE and JDK

JRE: Java Runtime Environment. It is basically the Java Virtual Machine where your Java programs run on. It also includes browser plugins for Applet execution.

JDK: It’s the full-featured Software Development Kit for Java, including JRE, and the compilers and tools (like JavaDoc, and Java Debugger) to create and compile programs.

Usually, when you only care about running Java programs on your browser or computer you will only install JRE. It’s all you need. On the other hand, if you are planning to do some Java programming, you will also need JDK.

If you are a beginner or you simply want to learn Java you can go ahead and download the JDK ( Java Development Kit) for the Java SE edition. Simply download and install the exe file by following the instructions.


Setting Java Path

  • The PATH is the system or user variable that your operating system uses to locate needed executables from the command line or Terminal window.
  • The PATH system or user variable can be set using System Utility in control panel on Windows, or in your shell’s startup file on Linux and Solaris.

In simple words, PATH helps the Operating System to find where Java is installed.
Setting Path on Windows
Note: You need to copy the location of the bin folder of the Java installation directory in the PATH’s value field.

Example for windows:

\ProgramFiles\Java\jdk-176\bin;

Windows 8

  1. Drag the mouse pointer to the Right bottom corner of the screen
  2. Click on the Search icon and type: Control Panel
  3. Click on -> Control Panel -> System -> Advanced
  4. Click on Environment Variables, under User Variables, find PATH, and click on it.
  5. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the java bin folder as the value.
  6. Close the window.
  7. Reopen Command prompt window, and run your java code.

Windows 7

  1. Select Computer from the Start menu
  2. Choose System Properties from the context menu
  3. Click Advanced system settings > Advanced tab
  4. Click on Environment Variables, under User Variables, find PATH, and click on it.
  5. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATHas the name and the location of the java bin folder as the value.
  6. Reopen Command prompt window, and run your java code.

Windows XP

  1. Start -> Control Panel -> System -> Advanced
  2. Click on Environment Variables, under User Variables, find PATH, and click on it.
  3. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATHas the name and the location of the class as the value.
  4. Close the window.
  5. Reopen Command prompt window, and run your java code.

Windows Vista

  1. Right-click My Computer icon
  2. Choose Properties from the context menu
  3. Click Advanced tab (Advanced system settings link in Vista)
  4. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATHas the name and the location of the class as the value.
  5. Reopen Command prompt window, and run your java code.

Setting Path on Solaris and Linux
To find out if the java executable is in your PATH, execute:

% java -version

This will print the version of the java executable if it can find it. If you get error java: Command not found. Then the path is not properly set.

To find out which java executable the first one found in your PATH, execute:

% which java

Below are the steps to set the PATH permanently,
For bash Shell:

  1. Edit the startup file
  2. (~/ .bashrc)
  3. Modify PATH variable:PATH="$PATH":/usr/local/jdk1.6.0/bin
  4. export PATH
  5. Save and close the file
  6. Open new Terminal window
  7. Verify the PATH is set properly
  8. % java -version

For C Shell (csh):

  1. Edit startup file(~/ .cshrc)
  2. Set Path
  3. set path="$PATH":/usr/local/jdk1.6.0/bin
  4. Save and Close the file
  5. Open new Terminal window
  6. Verify the PATH is set properly
  7. % java -version

Mac OS X 10.5 or later

In Mac OSX 10.5 or later, Apple recommends setting the $JAVA_HOME variable to

/usr/libexec/java_home

, just export $JAVA_HOME in file

~/. bash_profile

or

~/.profile
$ vim .bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
$ source .bash_profile
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home

Older Mac OSX
For older Mac OSX, the /usr/libexec/java_home doesn’t exists, so, you should set JAVA_HOME to the fixed path :

$ vim .bash_profile
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
$ source .bash_profile
$ echo $JAVA_HOME
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

Running a Java Program from command prompt

Editing, compiling, and executing
Graphical representation of Editing, compiling and executing
  1. Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java as shown in the HelloWorld example in the HelloWorld chapter.
  2. Save your file as HelloWorld.java in C:\mywork. To make sure your file name is HeloWorld.java, (not HelloWorld.java.txt), first choose “Save as file type:” All files, then type in the file name HelloWorld.java.
  3. Run Command Prompt (found under All Programs/Accessories in the Start menu).

Type:

1. C:\cd \mywork

This makes C:\mywork the current directory.

2. C:\mywork>; dir

This displays the directory contents. You should see HelloWorld.java among the files.

3. C:\mywork> javac HelloWorld.java

This runs javac.exe, the compiler. You should see nothing but the next system prompt…

4. C:\mywork>; dir

javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.

5. C:\mywork> java HelloWorld

This runs the Java interpreter. You should see the program output: Hello, World!

or check Java Hello World Example along with other Java Programming example

Ask your questions and clarify your/others doubts on Basic Java Syntax by commenting. Documentation

NEXT
JAVA HELLO WORLD!