Solved

Reading paramters passed to JVM

Posted on 2007-12-05
3
742 Views
Last Modified: 2008-02-01
I would like to pass a paramter into the JVM and have my code read it. So for example on the start up script for my app server I would pass a paramter like -Dprop.dir="some/dir". How would I go about doing something like this ?
0
Comment
Question by:apparition
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 20416120
String property = System.getProperty("prop.dir");
0
 
LVL 5

Author Comment

by:apparition
ID: 20416183
I tried this in eclipse but get an erro
java.lang.NoClassDefFoundError: =
Exception in thread "main"

here is the code
public class ReadParam {

      /**
       * @param args
       */
      public static void main(String[] args) {
            String home = System.getProperty("config.dir");
            
            System.out.println(home);

      }

}
When I run it I pass the following parameters in eclipse VM parameter box
-Dconfig.dir = "aasda"



0
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 20416242
> -Dconfig.dir = "aasda"

should be:

-Dconfig.dir=aasda
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
reverse digits of a number using for loop 5 52
hibernate insert example 13 34
Java syntax, or is it Selenium 6 30
web project error add remove 1 32
Most of the developers using Tomcat find it easy to configure the datasource in Server.xml and use the JNDI name in the code to get the connection.  So the default connection pool using DBCP (or any other framework) is made available and the life go…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question