Windows中javax.comm.properties的备用位置 [英] Alternate locations for javax.comm.properties in Windows

查看:92
本文介绍了Windows中javax.comm.properties的备用位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个程序,该程序需要安装在我对%JAVA_HOME%/lib没有写访问权的Windows机器上.

除了%JAVA_HOME%/lib之外,还有其他地方可以将javax.comm.properties移到其他地方吗?

I'm building a program that needs to be installed on Windows machines for which I do not have write access to %JAVA_HOME%/lib.

Is there anywhere else I can move javax.comm.properties to other than %JAVA_HOME%/lib?

根据Java COM API常见问题解答:

According to the Java COM API FAQ:

问:我的应用程序枚举可用端口时找不到任何端口 端口.
答:为了让Java通信API查找端口文件 javax.comm.properties必须放在正确的位置.首选 位置在/lib中.请参阅安装说明,以了解 备用位置和更多信息.

Q: My application does not find any ports when it enumerates available ports.
A: In order for the Java communications API to find ports the file javax.comm.properties must be in the correct place. The preferred location is in /lib. See the installation instructions for alternate locations and further information.

在哪里可以找到包含这些备用位置的Sun安装说明?

Where can I find the Sun installation instructions that contain these alternate locations?

推荐答案

我找到了一种对我有用的方法.要求如下:

I found a way that works for me. Here are the requirements:

  • comm.jar必须精确地命名为comm.jar(例如,不是comm-2.0.jar),并且必须位于类路径中精确命名为"lib"的目录中.
  • javax.comm.properties还必须具有该确切名称,并且必须与comm.jar位于同一目录中.
  • win32com.dll必须在java.library.path中引用.
  • comm.jar must be named exactly comm.jar (not comm-2.0.jar for example), and must be located in the classpath in a directory named exactly "lib".
  • javax.comm.properties must also have that exact name, and be located in the same directory as comm.jar.
  • win32com.dll must be referenced in the java.library.path.

因此,如果您具有这样的目录设置:

So, if you have a directory setup like this:

- lib\
   |- comm.jar
   |- javax.comm.properties
- ext\
   |- win32com.dll

然后,您可以在以下目录的根目录中使用以下java命令(假设带有YourMainClass的项目的jar文件也位于lib目录中:

Then you can use the following java command while in the root of these directories (assuming your project's jar file with YourMainClass is also in the lib directory:

java -Djava.library.path=.\ext -cp .\lib\* YourMainClass

有了这个,您不再需要在JRE的\bin\lib目录下放置任何内容.

With this, you should no longer need to put anything under the \bin or \lib directories of your JRE.

这篇关于Windows中javax.comm.properties的备用位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆