Java programming is widely used by almost maximum amount of developer. It is considered to be one of safest programming languages to code and develop apps and software for personal and commercial purposes. Learning Java programming has a wide range of opportunities in Web Development, Software development and research. Choosing Java as your main programming field has numerous scopes in Information Technology.
In today’s date Java is being used to develop apps for portable devices like mobile, hybrid tabs, etc. Java is also used in various gadgets and vehicles like car, video games etc.
In this article we have included the steps towards running your first Java Program using Notepad and Command Prompt (CMD).
First check if you have already installed Java using CMD. In order to check if Java is installed or not follow following steps –
Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file) where options include: -d32 use a 32-bit data model if available -d64 use a 64-bit data model if available -client to select the "client" VM -server to select the "server" VM The default VM is client.
If it gives different output something like command not recognized, it means you don’t have Java on your PC. Well, you can download and install the latest version of Java from java.com/en/download/
Once you have successfully installed Java on your PC, follow following steps to run your first Java Programme-
C:/
drive and create a new folder and name it Codes
C:/Codes/
class test { public static void main(String args[]) { System.out.print("Hello! Isrg Rajan"); } }
Codes
folder as test.java
cd C:/Codes
and pres enter (cd stands for change directory)javac test.java
javac
command is used to generate the java class file. In this case it will generate a class file named test.class
java test
to run your programmeIn order to set path in Java follow following stetps-
C:\Program Files\Java\jdkx.x.x_xx\bin\
using Windows explorerset path=[your JDK path]
And press enterThat’s all folks!