问题
is it possible to run a Jar twice?
e.g. consider a Jar which has 2 entry points. can I run them twice simultaneously, each time with an entry, without any kind of weird (like memory) problem?
回答1:
If your jar/application does not prevent a second start - yes If you start your application within different jvm's they are different processes which (usually) have no shared memory.
回答2:
Yeah, it's fine. You can run one jar files multiple times, like starting tomcat server twice, which is a pretty common setup. In my understanding, there is no memory leaking problem at all. On the contrary, modern JRE can enable class-sharing among multiple process, which can save considerable memory.
回答3:
Firstly, i dont think java interpreter alone understands multiple entry points. But you can write an application which understands this and launch the correct Main-class.
Secondly, even if java inrterpreter knew to launch multiple entry points it should be launching each in a separate JVM making it safe.
来源:https://stackoverflow.com/questions/10256395/running-a-jar-twice