Java for beginners

Posted by Andor on Jan 10, 2018, in Programming

Java is high level programming language that Sun Microsystems developed originally and James Gosling initiated it as well as released in the year 1995 as the core element Java platform of Sun Microsystems. It runs on various platforms like Mac OS, Windows as well as the different versions of UNIX. Java SE 8 is the current release of Java Standard Edition. Many configurations were created for suiting different kinds of platforms with the development of Java along with huge popularity. Like for example, J2ME for Mobile Applications, J2EE for Enterprise Applications. The new versions of J2 were renamed as Java EE, Java ME and Java SE. However, it is guaranteed to write once and run anywhere. 

History of Java

Java language project was initiated by Gosling in June, 1991` for using in many of his plenty top box projects. The language was initially known as ‘Oak’ after an oak tree that was present outside the office of Gosling. It even went by the term ‘Green’ and later ended up with the name ‘Java’ from a random words’ list. The first public implementation was released by Sun as Java 1.0 in the year 1995. It ensured Write Once, Run Anywhere, offering no cost run times on famous platforms. Much of Java was released by Sun on 13th November, 2006 as open and free source software under terms of GNU General Public License. The process was finished on 8th May, 2007, making each core of Java code open-source and code free, besides a little part of code to which Sun didn’t hold copyright. 

What you will need?

To run a Java program, you would require a Pentium 200 MHz computer with at least 64MB of RAM. You would even need software like Windows xp/7/8 or Linux 7.1 operating system, Java JDK 8 and Microsoft Notepad or any text editor. 

There are many advanced IDEs that are found in the market but you could even consider any one of the following:

  • Netbeans – It is one Java IDE which is free and open-source
  • Notepad – You can employ any kind of simple text editor on Windows machine such as Notepad or TextPad.
  • Eclipse – It is a Java that eclipse open-source community developed. 

Setting up local environment for Java

Just assume that Java is installed in C://Program Files/java/jdk directory. 

  • Right clicking on ‘My Computer’, select the option ‘Properties’
  • Now, You would be clicking the button of ‘Environmental variables’ that is present under the tab ‘Advanced’
  • You would be now altering the ‘Path’ variable, so that it consists of the path to Java executable. 

While considering a Java program, it could be defined as collection of objects which communicate through invoking methods of each other. Let’s have a look upon some terms important in Java.

  • Object – Objects possess behaviors and states. For example, a dog has states, i.e., name, breed, color and behavior like barking, wagging tail and eating. 
  • Class – It could be defined as a blueprint/template which explains the state or behavior that is supported by the object of its type. 
  • Methods – Basically it is a behavior. A class could consist of several methods. This is in methods where logics are written, data manipulation takes place as well as every action is performed.
  • Instance Variables – Every object possesses its special set of instant variables. The values that are assigned to the instance variable create the state of an object. 

How to save first Java Program

Let us a take a word ‘Hello’ and see how to compile, save a file as well as run the program. These are the steps:

  • You would be opening the notepad and add the code ‘Hello’
  • You would be saving the file like
  • Now, You would be opening a window of command prompt, going to the directory that contains the saved classes the class was saved
  • You will type now ‘javac’ and then press enter for compiling the above code. If the code has no errors, the command prompt would take you to next line
  • For running your program, type ‘java MyFirstJavaProgram’
  • Now, you will see the code ‘Hello’, printed on window. 

Java is employed in varied computing platforms from mobile devices and embedded devices to supercomputers and enterprise servers. It is a primary way to write in Java programming language for producing code which will be employed as byte code in Java Virtual Machine (JVM). 

Was this information useful?