英文:
Deploying Java application to a Linux computer
问题
我在Windows上使用Eclipse开发了一个桌面Java应用程序,它只是一个控制台应用程序。它使用了几个第三方的jar文件,在Windows上也需要一些第三方的dll文件。
在Windows机器上,我可以从命令提示符中运行这个应用程序,这个命令提示符是我从Eclipse中复制过来的。命令提示符在-classpath参数中引用了几个第三方的jar文件。在Windows的开发环境中,所有的dll文件都放在了项目主目录下。第三方的jar文件已经在项目属性的“Java Build Path”设置中包含在内。
现在,我想要将这个应用程序移植并在Linux计算机上部署运行。我应该怎么做?一种方法是在Linux机器上使用与Windows机器上相同的命令行,只需修改-classpath参数,将其指向Linux机器上的第三方jar文件的位置。这样做对吗?在Linux机器上,我还需要第三方的Linux本地的.so文件。我应该将它们直接复制到Linux机器上的项目目录中吗?项目目录结构是否应该与我在Windows开发机器上的结构相同?
还是我应该将所有内容导出(使用Eclipse导出)为一个jar文件,并使用"java -jar myapp"命令运行这个应用程序?在这种情况下,我应该把第三方的jar文件和本地的.so文件放在什么地方呢?
我已经在这个主题上阅读了很多,但仍然无法清楚地了解什么是最佳方法,特别是涉及第三方的.dll、.so和jar文件的情况。
英文:
I have developed a desktop Java application on Windows using Eclipse. It is just a console application. It uses several third party jar files and on Windows, several third party dll files are also required.
On the Windows machine, I can run the app from a command prompt as well, which I have copied from Eclipse. The command prompt references several of the third party jar files in the -classpath argument. In the development environment on Windows, all the dll files have been placed in the project home directory. The third party jar files have been included in the project Properties, "Java Build Path" setting on Eclipse.
Now, I want to move and run this app to a Linux computer for deployment. How should I do it? One way would be to use the same command line that is being used on the windows machine with modified -classpath arguments with the destination of third party jar files on the Linux machine. Is that the right approach? On the linux machine, I would also need the third party Linux native .so files. Should I just copy them to the project directory on the Linux machine? Should the project directory structure be same as the one I have on my Windows development machine?
Or should I just export (Eclipse Export) everything into a jar file and run the app using java -jar myapp command? Where should I place the third party jar files and native .so files in that case?
I have read a lot on this topic but still cant get any clarity on whats the best approach especially with third party .dll, .so and jar files involved.
专注分享java语言的经验与见解,让所有开发者获益!
评论