Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Executing Shell command in the same process

 
Srinivas Kothuri
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to run a shell command in the context of the current process in Java.
The way I know is using Runtime.getRuntime().exec() which will create a different process.
Actually I want to launching a browser in the same context of my java application.

Kindly tell me some work around for this.

Thank you in advance . . ..
 
Henry Wong
author
Marshal
Pie
Posts: 21117
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
None of the current variations of Unix or Windows allow multiple processes to share the same virtual address space. This is obviously done to protect the processes from each other. So... no. Java can't do that.

However, if you want to run two java programs, you can kinda simulate it by writing / running a wrapper that calls the main() method of the two classes.... but in that case, you have to be real careful that the two java programs don't step on each other. The OS don't know that they are two processes, and hence, doesn't provide any protection.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic