Centos7上运行jar包测试

Centos7上运行jar包测试

第一步:在本地打一个简单工程的jar包

请参考:这篇博客

第二步:上传jar包到Linux上

在这里我使用SecureCRT进行上传
当CRT连接上Centos后,按alt+P进入上传页面,并将本地jar包上传,本地jar包位置与上传截图如下:
在这里插入图片描述
在这里插入图片描述
查看jar包,并将jar包放入testjar目录中

[root@localhost etc]# cd ~
[root@localhost ~]# ls
anaconda-ks.cfg  docker-files                   kafka            模板  文档  桌面
apisix           helloCrontab-1.0-SNAPSHOT.jar  test_centos.tar  视频  下载
data             initial-setup-ks.cfg           公共             图片  音乐
[root@localhost ~]# mkdir testjar
[root@localhost ~]# mv helloCrontab-1.0-SNAPSHOT.jar ./testjar/
[root@localhost ~]# ls
anaconda-ks.cfg  data          initial-setup-ks.cfg  test_centos.tar  公共  视频  文档  音乐
apisix           docker-files  kafka                 testjar          模板  图片  下载  桌面
[root@localhost ~]# cd testjar/
[root@localhost testjar]# ls
helloCrontab-1.0-SNAPSHOT.jar
[root@localhost testjar]# 

第三步:运行jar包

[root@localhost testjar]# ls
helloCrontab-1.0-SNAPSHOT.jar
[root@localhost testjar]# nohup java -jar helloCrontab-1.0-SNAPSHOT.jar 
nohup: 忽略输入并把输出追加到"nohup.out"
[root@localhost testjar]# 

报错!!

报错解决(nohup: 忽略输入并把输出追加到"nohup.out")

# 创建日志收集的文件
[root@localhost testjar]# touch crontabstest.log 
# 将上面的执行命令换成下面的命令,便不报错了
[root@localhost testjar]# nohup java -jar helloCrontab-1.0-SNAPSHOT.jar >> crontabstest.log 2>&1
[root@localhost testjar]# nohup java -jar helloCrontab-1.0-SNAPSHOT.jar >> crontabstest.log 2>&1
[root@localhost testjar]# cat crontabstest.log 

nohup: 忽略输入
helloCrontab
[root@localhost testjar]# nohup java -jar helloCrontab-1.0-SNAPSHOT.jar >> crontabstest.log 2>&1
[root@localhost testjar]# cat crontabstest.log 

nohup: 忽略输入
helloCrontab
nohup: 忽略输入
helloCrontab
[root@localhost testjar]# 
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

?abc!

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值