Contrary to what many blogs seem to suggest – you need not and perhaps should not install any third party software for running a .java or .jar program on Windows 7, MAC & Linux.
The process is similar for all the three operating systems. Lets get started.
1) Step I: Download & Install Java SE Development Kit (JDK) or Java Runtime Environment (JRE)
First download the appropriate Java Platform from the Oracle Website.
Select and download the right platform depending upon your operating system (Windows 7, Windows XP/ MAC/Linux etc). Oracle provides two different choices of platform. Choose the one that is applicable to you.
End Users: If you simply want to run .java or .jar programs install the Java Runtime Environment (JRE)
After downloading the appropriate file – Install it. The JAVA environment is normally installed in:
1) C:/Program Files/Java – on the windows environment.
2.) usr/bin on Linux distributions like Centos, Gentoo, Debian, Ubutnu, Linux Mint, Mandriva, OpeSuse Fedora etc.
3) /Applications on MAC
We are now ready to run the .java or .jar program
2. Time to to run the .java or .jar program !
If you know how to compile and run any C or Python program – this method is very similar. Even if you have never compiled a program this should be easy – simple follow these steps
Step 1. Go to the Java installation directory >> C:/Program Files/Java (windows), usr/bin/Java(linux) or /Applications/Java (MAC)
Step 2. Open the folder named ‘bin’ (e.g C:\java\jre~~\bin or C:\java\jdk~~\bin)
Step 3. Copy the .java or .jre file that you wish to run into this ‘bin’ folder (say we want to run a file named XYZ.java)
Step 4. Open the command prompt in Windows 7 or terminal windows in Linux or Mac (Types and search CMD for windows users, for MAC & Linux users – i assume that you know how to open the Command line interface)
Step 5. Within the command line write: cd.. <address of your java/bin folder>
e.g for windows – this could read like cd.. c://Program Files/Java/jre.bla.bla/bin
Step 6. Compile the .java or .jre file using command Javac XYZ.java (replace XYZ.java with the original java file you want to run)
Step 7. Run the program by typing java XYZ (note – i did not use .java extension in this step, but used the .java extension after XYZ in previous step)
– this will run your Java program with .java or .jre extension