Responsive Ads Here

Monday 23 November 2015

Java Setup

Installing java?



Various editions of Java:
  • Java SE : stands for Java 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(mobile)edition for applications which run on resource constrained devices(small scale applications) like Cell phones,for example games.
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 Debuger)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 ot you simply want to learn Java you can go ahed and download the JDK(Java Development Kit) for the Java SE edition. Simply download and install the exe file by following the instructions.

Setting Path variable

  • The PATH is the system or user variable that your operating system uses to locate needed executable 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.
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:
  • Drag the mouse pointer to the right bottom corner of the screen.
  • Click on the Search icon and type:Control Panel.
  • Click on->Control Panel ->System->Advanced
  • Click on Environment Variables under User variables, find PATH, and click on it.
  • 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.
  • close the window.
  • reopen command prompt window,and run your java code,
Windows 7:

  • Select Computer from the Start menu
  • Choose System Properties from the context menu.
  • Click Advanced System settings > Advance tab.
  • Click on Environment Variables, under User Variables,find PATH , and click on it.
  • In the Edit windows,modify PATH by adding the location of the class to the value for 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.
  • Re open Command prompt window , and run your java code.
Windows XP:
  • Start-> Control Panel ->System->Advanced
  • Click on Environment Variables,under User Variables,find PATH, and click on it.
  • In the Edit windows,modify OATH by adding the location of the class to the value for 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.
  • Re open command prompt window, and run your java code. 
Compiling and Execution:
  • 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.
  • Save your files as HelloWorld.java in C:\mywork. To make sure your file name is HelloWorld.java(not HelloWorld.java.txt),first choose "Save as File type:| All files, then type in the File Name HelloWorld.java.
  • 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 java.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 Out put: Hello, world !.

1 comment: