Solved

Reading paramters passed to JVM

Posted on 2007-12-05
3
737 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
Comment Utility
String property = System.getProperty("prop.dir");
0
 
LVL 5

Author Comment

by:apparition
Comment Utility
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
Comment Utility
> -Dconfig.dir = "aasda"

should be:

-Dconfig.dir=aasda
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now