You should download JDK (Java Development Kit). You can find it here --> Java SDK. Go to link and download JDK for your platform.
After installing check that in your PATH variable added catalog with java.exe and javac.exe if not, add to it directory path with java.exe and javac.exe files. For example, my path is D:\JavaTools\jdk_1.7\bin. If you does not have PATH variable - create it. And create variable with name JAVA_HOME, and its value will be path to directory where you installed JDK (example, D:\JavaTools\jdk_1.7). To check is all good you can run consol (Windows+R) and input line - java. You must get this result:
| Usage: java [-options] class [args...] |
| (to execute a class) |
| or java [-options] -jar jarfile [args...] |
| (to execute a jar file) |
| where options include: |
| -client to select the "client" VM |
| -server to select the "server" VM |
| -hotspot is a synonym for the "client" VM [deprecated] |
| The default VM is client. |
It's mean that virtual machine was found but you called it with wrong arguments. If you get message «’java’ is not recognized as an internal or an external command, operable program or batch file», you did something wrong.
Open Notepad and save file HelloWorld.java:
| public class HelloWorld |
| { |
| public static void main(String[] args) |
| { |
| HelloWorld hw = new HelloWorld(); |
| hw.showString(); |
| } |
| public void showString() |
| { |
| System.out.println("Hello, World!"); |
| } |
| } |
Open console and go to directory with you file, input javac HelloWorld.java . You file was compiled!
After compilation you get file HelloWorld.class. Now you can start your application input string java HelloWorld
No comments:
Post a Comment