Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anything like VirtualEnv for Java?

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

like image 962
Gautam Avatar asked Sep 04 '11 15:09

Gautam


People also ask

Is there virtual environment in Java?

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes what is required in a JVM implementation.

Is virtualenv just for Python?

A Python virtualenv is a standalone Python environment, where you can install only the packages that you need for your project.

Is VENV better than virtualenv?

These are almost completely interchangeable, the difference being that virtualenv supports older python versions and has a few more minor unique features, while venv is in the standard library.

Should I use Anaconda or virtualenv?

As you see, if we are integrating both the frontend and machine learning setup, we need to use the python virtualenv. If we are going to use only the data science or machine learning setup, it's good to use the anaconda itself.


1 Answers

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

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.

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).

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.

like image 170
Joachim Sauer Avatar answered Sep 25 '22 13:09

Joachim Sauer