Specifically if you are a new Java programmer or a new Java programmer on Windows 7, you will probably need to set up an environment first for Java.
Alternatively though you may need tools like Eclipse, but to go in hard code Geek way, here is what you need to do…
- Right click Computer from the Start menu
- Choose System Properties from the context menu
- Click Advanced system settings > Advanced tab
- Click on Environment Variables, under System Variables, find PATH, and click on it.
- PATH probably will be C:\Program Files\Java\jdk1.7.0\bin\
- Reopen Command prompt window, and run your java code.
Also To Compile & Execute code as always have these commands :
Compilation javac ExampleProgram.java
Execution java ExampleProgram
Sometimes in the initial startup you may face an Error or might have trouble compiling and running Java code. An error like "Error: Could not find or load main class <classname>” is quiet common.
To solve which You must ensure that you add the location of your
.class file to your classpath. So, if its in the current folder then add
. to your classpath.
Example : javac -classpath .; *.java