Starting with Java?
Well, the first step as a newbie would be to install JDK - Java Development Kit. In earlier versions of JDK, there used to be a private JRE (Java Runtime Environment) as well as a public JRE as well. In later versions, the structure is changed, and we get only one folder of JDK, with private JRE. No Public JRE.
With the latest JDK version 16 in the market, one should still always go for the version which provides LTS - Long Time Support.
Currently, one should opt for Java SE 11 (LTS).
Now, Before running a program from the command line in java, things to be taken care of:
A. Set PATH variable in environment variables. It will tell the OS where the java executables like javac, java.exe are located. Set it to point
JDK version/bin folder
B. Then, check if the classpath is set already?
Classpath will tell the java interpreter where to find java class file to run.
If it is not, leave it as it is. If it is already set to some value, make sure you add, current directory in that as well. Denote current directory by
C. To run a program from the command line, go to the source root folder and then run the execute java command along with a fully qualified package name. i.e., java com.rajnesh.MainClass
Running it from anywhere else would throw this exception: