在OS X上安装JAR文件的位置,以便其他Java应用程序可以找到它们? [英] Where to install JAR files on OS X so other Java applications will find them?

查看:105
本文介绍了在OS X上安装JAR文件的位置,以便其他Java应用程序可以找到它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想安装不同的JAR文件,比如OS X上的数据库JDBC驱动器,以便其他Java应用程序可以找到它们。

I want to install different JAR files, like database JDBC drives on OS X so other Java applications will find them.

我应该把它们放在哪里?我尝试了〜/ Library / Java / Extensions 但它没有接缝工作。

Where am I supposed to put them? I tried ~/Library/Java/Extensions but it doesn't seam to work.

详情:

OS X 10.8.2

java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)

注意:我无法控制应用程序的初始化方式,但我确实假设应用程序没有包含它自己的Java发行版并且它将启动操作系统安装版本(可从命令行获得的版本)。

Note: I do not have control over how the application is initialized, but I do assume that the application does not incude it's own Java distribution and that it will start the OS installed versions (the one that is available from the command line).

此外,我没有任何CLASSPATH设置,请记住环境变量可用于命令行程序与OS X上的GUI应用程序可用的程序不同。

Also, I do not have any CLASSPATH setup, and please remember that environment variables that are available to command line programs are not the same as the ones available to GUI apps on OS X.

我需要指定我为我的开发机器尝试此操作这种方法不是部署Java应用程序的方法。

I need to specify that I am trying this for my development machine and that this approach is not a way of deploying Java applications.

推荐答案

请不要这样做。原因如下:其他应用程序将中断,因为将为每个Java应用程序加载这些JAR文件。

Please DON'T do this. Here's why: Other apps will break, because those JAR files will be loaded for every Java app.

详细信息:我为Mac销售Java应用程序。它依赖于具有特定的最新版本的JAR文件(对于JFreeChart)。有时在相应的Extensions文件夹中存在相同JAR文件的旧版本。这打破了我的应用。

In detail: I sell a Java app for Mac. It relies on having a specific recent version of a JAR file (for JFreeChart). Sometimes there is an older version of the same JAR file in the appropriate Extensions folder. This breaks my app.

但如果你真的想这样做:根据 Apple的文档

But if you really want to do this: According to Apple's docs:


扩展库

其他平台上的Java软件经常使用JDK安装中的
$ JAVA_HOME / lib / ext目录来存储
支持类或jar文件。虽然Java for Mac OS X还包含
lib / ext目录,但开发人员不应该直接修改它,因为
与上面提到的原因相同。 / Library / Java / Extensions目录
可用于需要在系统类路径上放置
的其他jar文件或JNI库。
对于更受控制的访问,
~ / Library / Java / Extensions目录可用于支持库的用户级
安装。放置在这些
目录中的项目不需要在应用程序的类路径中命名,并且
将可用于在相应范围
(系统级或用户级别)下运行的所有应用程序。取决于使用的目录。)

Java software on other platforms often makes use of the $JAVA_HOME/lib/ext directory within a JDK installation to store support class or jar files. While Java for Mac OS X also contains a lib/ext directory, developers should not directly modify it for the same reasons mentioned above. The /Library/Java/Extensions directory can be used for additional jar files or JNI libraries that need to be placed on the system classpath. For more controlled access, the ~/Library/Java/Extensions directory can be used for user-level installation of support libraries. Items placed in either of these directories do not need to be named in an application's classpath and will be available to all applications run under the respective scope (system-level or user-level, depending which directory is used).

这篇关于在OS X上安装JAR文件的位置,以便其他Java应用程序可以找到它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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