简体   繁体   English

Linux上库的Java文件夹在哪里

[英]Where is the java folder for libraries on linux

I need to find \\jre\\lib\\ext under the java folder to add libraries. 我需要在java文件夹下找到\\ jre \\ lib \\ ext来添加库。 And I am not sure how to find it 而且我不确定如何找到它

Use String extDir = System.getProperty("java.ext.dirs"); 使用String extDir = System.getProperty("java.ext.dirs"); to get the extensions dir path as you want (more info about system properties can be found here ), set the path and write the jar files to that directory (be carefull to capture any IOException that could be raise in the writing process because this folders are usually write-protected or require root/admin privileges) 要获取所需的扩展目录路径(有关系统属性的更多信息,请参见此处 ),设置路径并将jar文件写入该目录(请小心捕获在编写过程中可能引起的任何IOException,因为此文件夹通常具有写保护或需要root / admin权限)

As quoted in the comments, this is something that should only be done in exceptional cases 如评论中所引用,这仅应在特殊情况下进行

As most comments say don't do so, the alternative. 正如大多数评论所说的那样,替代方法。

Most applications have an app .jar and a lib folder in which all library jars reside. 大多数应用程序都有一个app .jar和一个lib文件夹,所有库jar都驻留在其中。 In the application jar there is a META-INF/MANIFEST.MF with a class path including the lib jars. 在应用程序jar中,有一个META-INF / MANIFEST.MF,其类路径包括lib jar。

As a developer I use maven (like ant, ivy) for the build infra structure and it does it just so. 作为开发人员,我使用maven(如ant,ivy)构建基础结构,它就是这样做的。 The jars are taken from the local maven repository else from the remote ones. 这些罐子是从本地Maven存储库中获取的,而其他则是从远程Maven存储库中获取的。 Also maven uses a local repository of all jars in different versions. 而且,maven使用所有版本不同的jar的本地存储库。 Jars missing in the remote repositories, like own programming, can be installed there. 远程存储库中缺少的jar可以像自己编程一样安装在此处。

BTW /usr/lib/jvm/ contains the java versions (do which java , which javac ). 顺便说一句, / usr / lib / jvm /包含Java版本(do which javawhich javac )。

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

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