用Eclipse编写hello world上传到GitHub

 

一、下载安装开发工具

(一)下载安装Eclipse

下载链接: Eclipse Downloads | The Eclipse Foundationicon-default.png?t=L892http://www.eclipse.org/downloads/

   (二)下载安装jdk1.8

下载链接:Java Downloads | Oracleicon-default.png?t=L892https://www.oracle.com/java/technologies/javase-downloads.html

二、编写hello world.java

1.File—>New—>Java Project

2. 在Project name输入项目的名字(自定义),在use an execution enviornment JRE 中选择javaSE-1.8,点击Finish

 3.在左侧找到刚刚创建的项目并点击右键,找到New,点击右侧的Class

4, 先在Name填写文件名,把public static void main(String[] args) 打勾上,点击Finish

 5.输入“hello world”代码

 6.在左侧找到刚刚创建的项目并点击右键,找到Run As,点击右侧的Java Application

 7.代码运行成功,在控制台显示出来

三、进入github注册登录 

(一)进不去github解决方法

1.访问以下两个网址

▷ GitHub.com : GitHub: Where the world builds software · GitHubℹ️ GitHub is the best place to share code with friends, co-workers, classmates, and complete strangers. Over four million people use GitHub to build amazing... | GitHub - github.com Website Statistics and Analysishttp://github.com.ipaddress.com/

▷ github.global.ssl.Fastly.net Website statistics and traffic analysis | Fastly | fastly.netℹ️ Fastly - Get extensive information about the hostname including website and web server details, IP addresses, DNS resource records, server location, Reverse DNS lookup and more | fastly.net Website Statistics and Analysis about github.global.ssl.fastly.nethttps://fastly.net.ipaddress.com/github.global.ssl.fastly.net获取两个IP地址

2、打开本地host文件

C:\Windows\System32\drivers\etc

添加

# 访问 github

140.82.114.4 github.com

199.232.69.194 github.global.ssl.fastly.net

(两个IP地址)

3、更新DNS缓存

若还是不能访问,打开CMD运行如下命令 ipconfig /flushdns 再试一下

(二)注册登录github账号

注册登录地址: 

https://github.com/icon-default.png?t=L892https://github.com/

四、Eclipse与github关联发布

(一)在Eclipse上安装GIT插件EGit

1.找到Help->Install New Software...

 点击Add...->Name:EGit->Location:填入EGit插件地址

EGit插件地址:

http://download.eclipse.org/egit/updates

连续下一步默认安装,再重启Eclipse

(二)Eclipse配置git信息

1.Window–>Preferences–>Version Control(Team)–>Git–>Configuration->User Settings->

Add Entry…

key:user.name,value:github注册时的名字->Add

 key:user.email,value:github注册的邮箱账号->Add

点击Apply and close


2.Eclipse配置SSH

Window -> preferences ->general ->Network Connections -> SSH2->Key Management

->Generate RSA Key...->Save Private Key...->Apply and Close

 3.生成一个id_rsa.pub文件

 可以在Eclipse中打开该文件查看复制文件内容

 

4. 登陆github,点击右上角头像下的settings

点击SSH and GPG keys,点击 New SSH Key

 输入title值(自定义),key粘贴id_rsa.pub文件的文件内容

5. 如下图所示则为配置成功

 (三)在github上新建仓库

1.进入github后点击右上角的头像,找到your repositories,点击进去查看仓库

 

 2.进去后找到并点击绿色的New 按钮创建仓库

 3.输入仓库的名字,打勾前面两个,第二个选上java,点击Create repository

  4.如图所示,仓库创建成功

5,获取github仓库地址

SSH

 (四)提交项目到本地仓库(Git)

1.右键项目–> Team–> Share Project

打√,别忘记点击Create Repository->Finish

2. 右键项目–> Team–> Commit...

 选择要提交的内容

 

别忘记在Commit Message框内随便输入些东西,点击Commit按钮,即完成提交本地仓库操作

(五) 提交项目到远程仓库(Github)

 1.右键项目–>Team–>Remote–>Push...

 

粘贴github仓库地址、User不要改动,输入github密码后点击Next

 2.在Source ref选择master>>再点击Add Spec>>在force update框中打勾>>点击Finish,完成远程仓库提交

3. 在github仓库中可以查看发布成功的状态,以后的项目都可以直接发布

 五、总结

以上就是我对如何安装使用Eclipse实现代码编写及上传到GitHub的的学习和整理,希望这篇文章会对你有帮助,如果有什么问题欢迎在评论区提出一起交流,错误之处也希望大家能指出来。

另外在粘贴仓库地址时用https会报错失败,查找解决办法很多但是都说的不太详细,导致问题没有解决,如果有大佬愿意详细讲解就感激不尽了。

六、引用

Eclipse + GitHub +“hello world”_Mika-的博客-CSDN博客文章目录(一)开发工具下载与安装1.1 jdk1.8下载与安装1.2 Eclipse下载与安装(二)java的hello world程序编写(三)github注册登录(四)java项目发布至github4.1 直接拖动文件发布4.2 Eclipse与github关联发布4.2.1 Eclipse配置git信息4.2.2 Github新建仓库4.2.3 提交项目到本地仓库(Git)4.2.4 提交项目到远程仓库(Github)(一)开发工具下载与安装1.1 jdk1.8下载与安装jdk包括了Java运行https://blog.csdn.net/weixin_44029146/article/details/115059818

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值