简体   繁体   English

如何在可执行的Java应用程序安装过程中自动设置类路径?

[英]How to set a classpath automatically during the installation of an excutable java application?

I am writing down an example of what I was trying to do. 我正在写一个我想做的事的例子。 But this is just one example, I am sure there would be many. 但这只是一个例子,我敢肯定会有很多。 So I want a generalised answer for this. 所以我想要一个概括的答案。

I was trying to make a java desktop application which reads the word documents. 我试图制作一个读取Word文档的Java桌面应用程序。 I realized I need some Apache libraries/APIs that would help me do it. 我意识到我需要一些Apache库/ API来帮助我做到这一点。 So I downloaded the library. 所以我下载了图书馆。

But now I need to set the classpath of the files from the library. 但是现在我需要设置库中文件的类路径。

I am a developer and I can do it, but imagine giving such instructions of setting a classpath to a complete non-developer user. 我是一名开发人员,我可以做到,但是可以想象给完全的非开发人员用户提供此类设置类路径的说明。

I was wondering if when I am over with the making of this java application, I would make it executable (exe) application and when someone installs it, the classpaths are set automatically during the installation and the apache library files are automatically extracted. 我想知道是否可以在完成该Java应用程序时使其成为可执行(exe)应用程序,并且当有人安装它时,在安装过程中会自动设置类路径,并自动提取apache库文件。

How can I do it? 我该怎么做? Can someone explain me in detail - step-by-step? 有人可以逐步详细解释我吗?

Please consider using some development IDE, like (free) eclipse for instance. 请考虑使用一些开发IDE,例如(免费)eclipse。 Then crate new folder (clled lib for example) in your project, copy the library into it, then click on your library by the right button and select "add to build path" 然后在您的项目中创建新文件夹(例如,clled lib),将库复制到其中,然后通过右键单击您的库并选择“添加到构建路径”

As already mentioned - best way to do it is to use Manifest file in your jar. 如上所述,最好的方法是在jar中使用清单文件。 Official documentation: https://docs.oracle.com/javase/tutorial/deployment/jar/downman.html 官方文档: https : //docs.oracle.com/javase/tutorial/deployment/jar/downman.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM