Is there anything like VirtualEnv for Java?

2020-03-01 03:54发布

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

8条回答
闹够了就滚
2楼-- · 2020-03-01 04:33

I have also been looking for a similar solution to simplify switching context between projects that use different Maven versions/settings and/or Java SDKs without having to modify M2_HOME and JAVA_HOME settings every time.

To this end, I developed a solution that helps execute mvn commands with the appropriate configuration based on per-project settings (stored in a .mvn folder).

See: https://github.com/AlejandroRivera/maven-env

Be aware that this only helps if you're using Maven to build and/or run your project.

查看更多
对你真心纯属浪费
3楼-- · 2020-03-01 04:36

I'm confused by the assertion that "Java doesn't have the concept of a 'system-wide installed' library". What would you call the jar files in $JAVA_HOME/jre/lib and $JAVA_HOME/jre/lib/ext?

Regardless of whether or not Java "needs" a tool like virtualenv, it seems that something that allowed you to quickly switch between different Java environments (e.g. Java 6 with such-and-such security extensions, Java 7, etc.) would be handy - even if all it was actually doing under the covers was manipulating the PATH, JAVA_HOME, and CLASSPATH env variables.

查看更多
登录 后发表回答