将本地Java程序部署到linux服务器并执行
来源:互联网 发布:工程预算网络课程 编辑:程序博客网 时间:2024/05/21 10:45
问题:该程序本地运行正常,服务端运行报错找不到第三方包中的类
原因:本地打jar包时有错,未能正确引入第三方包
解决:本地通过fat jar插件来打包,方法如下
在Eclipse 下 java 应用程序打包 Mainfest.mf 格式
首先保证程序在Eclipse下的正常执行,然后方法如下:( 写在最前面 做好的Eclipse打包 还是使用插件 Fat jar)
下载地址 :http://sourceforge.net/project/showfiles.php?group_id=115990&package_id=125924
使用说明:
Fat Jar Eclipse Plug-In Tutorial
Create a new Java Project named "demolib".
Add the Class "demolib.DemoLib.java" containing the following code:
package demolib;
public class DemoLib {
public static void sayHello() {
System.out.println("Hello");
}
}
The Project should look something like this:
In the "Package-Explorer" (not the "Resource-View") right click on the project "demolib".
Select "+ Build Fat Jar".
A Configuration Dialog appears. Just press "Finish".
The File "demolib_fat.jar" has been created in the project root directory.
Create a new Java Project named "demorun".
In the project properties add the Library "demolib/demolib_fat.jar" to the Java Build Path":
Add the Class "demorun.DemoRunMain.java" containing the following code:
package demorun;
import demolib.DemoLib;
public class DemoRunMain {
public static void main(String[] args) {
DemoLib.sayHello();
}
}
The Project should look something like this:
Start the Export Wizard from the File-Menu ("File" -> "Export").
Select "+ Fat Jar Exporter" and click "next >".
Select the project "demorun" and click "next >".
A Configuration-Dialog appears showing the current Settings.
The Main Class - the one containing the static methode main - must be defined in the jar.
Click on the "Browse..." Button on the right side behind the Main-Class Edit field.
Select "DemoRunMain" and click the "OK" Button.
The FullyQualifiedName "demorun.DemoRunMain" is now set for "Main-Class".
Save the current Settings by clicking on the "Finish" Button.
In addition the file ".fatjar" storing the configuration settings has been created in the project root directory
The created jar file contains all classes from all referenced jar files (demolib_fat.jar) and the project classes.
This file can be executed anywhere, no classpath has to be set, because all necessary libraries
are extracted inside the "Fat Jar":
> java -jar demorun_fat.jar
Hello
- 将本地Java程序部署到linux服务器并执行
- 将java程序部署到Linux服务器上
- 将java项目部署到linux服务器
- 关于如何打包java程序(我的是一个聊天服务器),并将jar包部署到远程linux服务器上
- 将java程序发布到linux服务器
- linux上部署tomcat,用Nginx做反向代理,并将Java项目部署到服务器上
- 从零开始搭建web项目并部署到本地服务器
- 图片导出到excel本地正常,但将war包部署到Linux服务器上出现的问题
- java cmd 执行本地程序并对程序执行情况反馈
- 本地web项目部署到阿里云Linux服务器指南
- java 连接Linux服务器并执行指令
- java 连接Linux服务器并执行命令
- 获取Linux执行命令后的PID--管理部署在服务器的Java程序
- 使用java service wrapper将项目部署到linux服务器上
- 远程操作Linux下安装Tomcat服务器并安装部署Java Web程序
- Hdfs将服务器的整个文件夹拷贝到Linux本地
- 将linux本地文件夹上传到hdfs服务器
- 将web应用部署到Linux下面的tomcat服务器
- javascript面试题+吐槽解析版
- xcode5.0.2下国际化图文解说
- poj 1141 括号匹配升级版 区间DP
- 搞笑,快人一步
- wince 音频学习
- 将本地Java程序部署到linux服务器并执行
- @RequestMapping 用法详解之地址映射
- 中国工商银行数据中心笔试部分考题[真题]
- linux程序编译期加入编译时间和svn版本号
- mysql卸载后重装时出现问题解决方法
- 设置请求超时的时间
- android中的适配
- ctags 的一些实用细节!!
- 开通博客啦