Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > accessing VM command line from code

Reply
Thread Tools

accessing VM command line from code

 
 
angelochen960@gmail.com
Guest
Posts: n/a
 
      03-17-2009
Hi,

Is there a way to access VM command line parameters from a java code,
particularly a servlet ? Thanks

A.c
 
Reply With Quote
 
 
 
 
Giovanni Azua
Guest
Posts: n/a
 
      03-17-2009
Hi there,

<(E-Mail Removed)> wrote
> Is there a way to access VM command line parameters from a java code,
> particularly a servlet ? Thanks
>

You can use Runtime.exec:
http://java.sun.com/javase/6/docs/ap...g/Runtime.html

and execute the command "$JAVA_HOME/bin/jps -v"

then you have to:

1) Find the appropriate Servlet process e.g. the String contains tomcat
1) parse the output for all command line parameters ...

HTH,
regards,
Giovanni


 
Reply With Quote
 
 
 
 
Giovanni Azua
Guest
Posts: n/a
 
      03-17-2009
if you know the process id beforehand and assuming Unix environment then you
only need to execute:

"$JAVA_HOME/bin/jps -v | grep <pid>"

jps also works remotely so you can specify the remote host to connect to.

HTH,
regards,
Giovanni


 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      03-22-2009
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Is there a way to access VM command line parameters from a java code,
> particularly a servlet ? Thanks


The best I can find is:

RuntimeMXBean rtmb = ManagementFactory.getRuntimeMXBean();
for(String s : rtmb.getInputArguments()) {
System.out.println(s);
}

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difficulty accessing command line function return value (Hadoop FSshell) S D Ruby 0 02-16-2009 06:12 PM
accessing and storing character arguements from command line Dawn Minnis C Programming 9 02-28-2005 07:01 AM
accessing args via command line mark C++ 1 06-14-2004 02:35 AM
Accessing Command line on German Mac OS X? Josef 'Jupp' SCHUGT Ruby 2 03-07-2004 12:36 AM
RUN/execute a Command-Line command from an ASP page. Lucas Cowald ASP .Net 4 10-23-2003 11:09 AM



Advertisments