Text content is recorded bloggers learned from their own study notes.
If you have problems or there are different views, welcome!
1 install JDK
Download the JDK from Oracle's official website, I use the version 1.7.0.80.
Operating system is win7 64 bits, to select the corresponding version of the JDK.
Official website address:
The installation path do not have Chinese and spaces, do not check the public JRE installation.
After installation, the installation package to keep the version number of names.
win + r open the Run window, open a command prompt type cmd
Enter java -version
If you have show java version information, the installation was successful.
2 configuration environment variable
(1) New JAVA_HOME
Computer - Properties - Advanced System Settings - Advanced - Environment Variables - System Variables - New
Variable name: JAVA_HOME
Variable values: E: \ Basic \ programmer \ jdk7.80
(2) Edit Path
Find Path, edited, added after the original value ";% JAVA_HOME% \ bin"
Everything between the double quotes, pay attention to the first symbol is the English form of the semicolon, do not ignore or labeled in Chinese.
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;;%JAVA_HOME%\bin;
(3) New CLASSPATH
The same location, system variables - New
Variable name: CLASSPATH
variable:
.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
配置完成后,在运行窗口输入cmd,在命令提示符中分别输入java和javac,两个命令都能显示相关信息就说明配置成功了。
如果显示为:不是内部或外部命令,就说明没有配置成功。
请仔细检查是否有步骤忽略、多余步骤、编辑输入错误等。
3创建第一个程序
也就是敲代码,现在可以不用知道这个程序是如何创建出来的,直接复制粘贴代码即可,这个程序后续会学习。
在硬盘根目录下,创建一个TXT格式的文本,输入代码,一共5行如下:
public class HelloWorld {
public static void main(String[] args){
System.out.println("Hello,Java");
}
}
代码输入完成后,将新建文档命名成HelloWorld,后缀名改成.java。修改完成后点击盘符中的地址,输入cmd
这个方法进入的命令提示符,自动会切换到HelloWorld.java文件所在的硬盘。
其他方法进入则需要手动切换,手动切换方法,我的是E盘,所以输入E:即可。英文状态的冒号。
在命令提示符窗口中输入javac HelloWorld.java
然后可以在之前新建文档的硬盘,也就是HelloWorld.java所在的目录看到一个同名但后缀是.class的文件。
在命令提示符窗口中输入,java HelloWorld
即可运行程序,这个程序的作用就是输入显示一句话。Hello,Java
此时,JDK成功安装、环境变量配置成功、程序运行成功。
前两项都是一次性的,只要不出现问题,以后不再重新配置。
我们之后的学习多数都将集中在如何创建程序上,
在这篇博客中,给学习java的童鞋们一些建议。
也算是给曾经的自己一些建议。
1文中的许多操作都有其他的方法可以达成同样的效果。
这对于熟悉的人来说如虎添翼,对于初学者则不那么友好。
因为初学时容易分不清是完全一样,还是有细微的差别。
如果想要尝试不同的方法,可以先将这三步都成功一次。
然后卸载jdk、还原配置、删除代码,再来一次。
2初学时,安装JDK、配置环境变量、创建运行第一个程序
看视频教程比看文字教程好,因为生动形象,也更详细。
当然啦,看完视频教程,也会写文字类的笔记吧,哈哈哈。