是否有类似VirtualEnv for Java的东西? [英] Is there anything like VirtualEnv for Java?

查看:66
本文介绍了是否有类似VirtualEnv for Java的东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于Java或JVM语言,是否有类似于Python virtualenv 的东西.?

Is there anything similar to Python virtualenv for Java or JVM Languages?

推荐答案

据我了解,virtualenv使您能够拥有单独的库安装路径,有效地分隔虚拟" Python安装.

From what I understand, virtualenv enables you to have separate library installation paths, effectively separate "virtual" Python installations.

Java没有已在系统范围内安装"库的概念(*):它始终在类路径中搜索要加载的库.由于可以为每个应用程序定义类路径,因此每个应用程序都可以选择要加载的库和版本.

Java doesn't have the concept of a "system-wide installed" library(*): It always searches the classpath for the libraries to be loaded. Since the classpath can be (and needs to be!) defined for each application, each application can pick-and-choose which libraries and which versions it wants to load.

如果您更深入地了解一个单一的应用程序,而该应用程序某种程度上需要同时使用同一库的两个不同版本,那么您甚至可以使用一些类路径技巧来做到这一点.它可能会变得复杂,但是绝对有可能(OSGi是支持此功能的一个示例,即使具有两个独立Web应用程序的Tomcat都可以做到这一点.)

If you go down one level deeper and have a single application that somehow needs two different versions of the same library at the same time, then you can do even that with some classpath trickery. It can get complicated, but it's definitely possible (OSGi is one example where this is supported, even Tomcat with two separate webapplications does this).

我在virtualenv描述中看到了一些安全性参考:Java内置了相当全面的安全性系统.在服务器应用程序中,通常会关闭它,因为这样做更容易配置,但是您可以轻松地配置允许使用Java应用程序.

I've seens some references to security in the virtualenv description: Java has a pretty thorough security system built in. In server applications it's often turned off because it's just easier to configure this way, but you can easily configure what exactly a Java application is allowed to do.

(*)几乎有扩展或扩展库,但是它们使用不多,甚至可以轻松地从任意目录中加载它们.

(*) Almost, there are extensions or extension libraries, but they aren't used a lot and even those can easily be loaded from arbitrary directories.

这篇关于是否有类似VirtualEnv for Java的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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