Java从0开始写HelloWorld
原创约 1080 字大约 4 分钟...
Java从0开始写HelloWorld
注意
本博文仅供学术研究和交流参考,严禁将其用于商业用途。如因违规使用产生的任何法律问题,使用者需自行负责。
事先准备
- Java环境安装
- Eclipse工具下载安装
- Eclipse设置环境变量
- Eclipse 导入 注释横版
codetemplates.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="false" context="methodcomment_context" deleted="false" description="Comment for non-overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment">/**<p>Title: ${enclosing_method}</p>
* <p>
* Description:
* </p>
* <p>Copyright: Copyright (c) 2017</p>
* <p>Company: www.baidudu.com</p>
* ${tags}
* @author xianxian
* @date ${date}
* @version 1.0
*/ </template><template autoinsert="false" context="gettercomment_context" deleted="false" description="Comment for getter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment">/**
* @return the ${bare_field_name}
*/</template><template autoinsert="false" context="fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/**
* ${field}
*/ </template><template autoinsert="false" context="overridecomment_context" deleted="false" description="Comment for overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment">/* (non-Javadoc)
* <p>Title: ${enclosing_method}</p>
* <p>
* Description:
* </p>
* <p>Copyright: Copyright (c) 2017</p>
* <p>Company: www.baidudu.com</p>
* ${tags}
* ${see_to_overridden}
* @author xianxian
* @date ${date}
* @version 1.0
*/</template><template autoinsert="false" context="settercomment_context" deleted="false" description="Comment for setter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment">/**
* @param ${param} the ${bare_field_name} to set
*/</template><template autoinsert="false" context="typecomment_context" deleted="false" description="Comment for created types" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment">/**<p>Title: ${type_name}</p>
* <p>
* Description:
* </p>
* @author xianxian
* @date ${date}
*/ </template><template autoinsert="false" context="filecomment_context" deleted="false" description="Comment for created Java files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">/**<p>Title: ${file_name}</p>
* <p>
* Description:
* </p>
* <p>Copyright: Copyright (c) 2017</p>
* <p>Company: www.baidudu.com</p>
* @author xianxian
* @date ${date}
* @version 1.0
*/ </template><template autoinsert="false" context="modulecomment_context" deleted="false" description="Comment for modules" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.modulecomment" name="modulecomment">/**
* @author ${user}
*
* ${tags}
*/</template><template autoinsert="false" context="delegatecomment_context" deleted="false" description="Comment for delegate methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">/**
* ${tags}
* ${see_to_target}
*/</template><template autoinsert="false" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/**<p>Title: </p>
* <p>
* Description:
* </p>
* ${tags}
*/</template></templates>
- 调整字体大小 window - preferences - general - apprearance - colors and fonts - basic - text font - edit编辑字体大小
- 修改项目编码格式 项目右键 - properties - resource - text file encoding - 选择对应的编码格式(GBK中文、UTF-8通用)
- 熟悉Eclipse常用的快捷键 例如:alt + / 快速生成方法 /** + Enter 生成注释
- 右边标识JvaEE与Java 选择Java
- .新建对应的Java包和类
开发代码
package com.tencent.chapter01;
/**
* <p>Title: HelloWorld</p>
* <p>
* Description:
* 注释分三种:
* 1.文档注释,修饰class与class中的成员(成员变量与成员方法)
* 2.单行注释,注释一行代码
* 3.多行注释,注释一块代码
* </p>
* @author xianxian
* @date 2023年1月2日
*/
public class HelloWorld {
/**
* <p>Title: main</p>
* <p>
* Description:
* 主函数(程序的入口函数)
* </p>
* @param args 参数信息
*/
public static void main(String[] args) {
//单行注释:快捷键(注释与解注释) ctrl + /
//System.out.println("你好,世界!!!");
//多行注释:快捷键(注释) ctrl + shift + / 快捷键(解注释)ctrl + shift + \
/*System.out.println("你好,世界!!!");
System.out.println("你好,世界!!!");
System.out.println("你好,世界!!!");
System.out.println("你好,世界!!!");
System.out.println("你好,世界!!!");*/
System.out.println("你好,世界!!!");
}
}
右键运行 Run as ---> 1 Java Application
导出JAVA项目快速生成文档
右键项目 --> Export --> Javadoc --> Next --> 选自己的项目 --> Next --> Next --> Finish --> Yes TO All

关键代码
-encoding UTF-8 -charset UTF-8
- 遇到的bug2

- 解决办法
Eclipse Java EXPORT Javadoc 错误: 未知标记: date

关键代码
-encoding UTF-8 -charset UTF-8 -tag date:a:”date”
项目右键 - build path - configure build path - library - 选中当前的jre system library - edit编辑为自己的版本
分割线
相关信息
以上就是我关于 Java从0开始写HelloWorld 知识点的整理与总结的全部内容,希望对你有帮助。。。。。。。
扩展知识
导入已存在Java项目
File - import - general - existing project into workspace - 选择需要导入的项目OK
修改项目JDK版本不一致
分割线
Powered by Waline v2.15.4