System property via comman-line argument

Hi!
I have to create new System property and set it during launch of my application. I'm doing it this way:
Properties p = new Properties(System.getProperties());
try {
  InputStream in = new ByteArrayInputStream(args[0].getBytes("UTF-8"));
  p.load(in);
  System.setProperties(p);
  System.out.println(System.getProperty("datastorage"));
  in.close();
catch(IOException e) {
  e.printStackTrace();
}Is it OK? Sometimes I saw in command-line some argument, which contained "-D" in the beggining and appeared to be propety. What is it for? Should I use that too? I didn't find anything about that notation.
Thanks!

What the heck are you trying to do here?
You can always specify system properties by using "-D" before the main method name (or jar name) on the command line:
java -cp . -DmyProperty=myValue my.MainClass

Similar Messages

  • How to set a system property via the config tool?

    Hello,
    how can I set a system property via the config tool? Before I chose WAS from SAP I used java with option -D<name>=<value> to set the system properties.
    Very much thanks in advance.
    Regards
    Carsten

    Hi Carsten,
    WAS config tool is located under
    e.g. usr\sap\J2E\JC00\j2ee\configtool
    start configtool.bat
    there will be opened a configuration tool GUI
    Click on the instance_ID.... leaf of the tree in the left pane and then on the server_ID.... leaf.
    Java settings will appear in the right pane after this steps.
    Best Regards,
    Violeta

  • Sending varargs via command line arguments to main()

    When I put A B C D in the command line arguments textbox in my compiler, the output is as expected: A B C D. However, when I put *new String[]{A, B, C, D}*, the output is *new String[]{A, B, C, D}*, not A B C D as I had expected. My code is below. Any suggestions?
    package varargs;
    public class Varargs {
        static void printArray(Object...args){
            for (Object obj : args)
                System.out.print(obj + " ");
            System.out.println();
        public static void main(String...args) {
            printArray((Object[])args);
    }

    The argument(s) that is/are supplied to your main method will be rendered as literal String constants. It looks like you are attempting to use java code as one of your arguments with the expectation that the program will interpret this code. It won't. Your program will simply display whatever it is given even if what you offer as an argument happens to be a construct of the Java language.

  • Changing the override file via command line arguments

    Is there a way to change name of the file Coherence uses to override coherence-config.xml via a command line argument? I'd like to specify different override filenames in different environments.

    I get the message that:
    2006-02-13 16:53:27.699 Tangosol Coherence 3.0.1/317 <D5> (thread=main, member=n/a): Optional configuration file "/home/noah/tools/tangosol-config/tangosol-coherence-override-dev.xml" is not specified
    I specified the following as the startup:
    java -Dtangosol.coherence.override=/home/noah/tools/tangosol-config/tangosol-coherence-override-dev.xml -Dtangosol.coherence.log.level=5 -classpath /home/ncohen/tools/tangosol-config:/home/noah/tools/tangosol/lib/coherence.jar com.tangosol.net.CacheFactory
    Where the tangosol-config directory contains my override file tangosol-coherence-override-dev.xml
    If I change the name of the override file solely in the cmd prompt, it doesn't find any of them. It just gives me the optional configuration file ..... is not specified. How does one go about fixing this? Thx.
    Message was edited by:
    noah

  • System date as Command line argument

    Hi
    Can we pass system date as commandline argument to a java program.
    If yes,How?
    thnx in advance

    A simple work-around:
    public class Test {
         public static void main(String[] argv) {
              if (argv.length != 0) {
                   if (argv[0].equalsIgnoreCase("date")) argv[0] = new java.util.Date().toString();
                   System.out.println(argv[0]);
    }

  • Operational override for write-delay (system-property)

    Hi all,
    I'm failing to get this xml element to validate within a cache config.
    I'm using Coherence 3.7.1
    <write-delay system-property="myproperty.override.write-delay" >10s</write-delay>.
    the idea is to get the write-delay value atruntime through a system-property (-Dmyproperty.override.write-delay=5s for ex.)
    I'm getting the following failure
    Description
    Location
    Type
    cvc-type.3.1.1: Element 'write-delay' is a simple type, so it cannot have attributes, excepting those whose namespace name is identical to 'http://www.w3.org/2001/XMLSchema-instance' and whose [local name] is one of 'type', 'nil', 'schemaLocation' or 'noNamespaceSchemaLocation'. However, the attribute, 'system-property' was found.
    line 41
    XML Problem
    Do you know if the override is valid at that location? The documentation says YES.
    What am I doing wrongly?
    Thanks,
    Harry

    Hello Leo_TA,
    thanks for the answer.
    Actually I need a default value which can be overriden at runtime as described in the documentation
    http://docs.oracle.com/cd/E18686_01/coh.37/e18677/appendix_cacheconfig.htm#BHCECGCF
    This is very handy to move conifguration items outside the cache-config.
    Do you know why the xml woul dnot validate when system-property is used in the write-delay?
    <?xml version="1.0" encoding="UTF-8"?>
    <cache-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config"
                  xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">
    </cache-config>
    Coherence accepts it (when we force no xml validation (removing the xmlns)).
    But I would like to use the xml validation to avoid miss-configurations.
    Regards
    Harry

  • System property 'primavera.bootstrap.home' not found error while starting P6 application via managed server

    Hi All,
    I had installed P6 8.3 with weblogic 10.3.6.
    My Adminserver is running.
    But when i am starting my managed server P6, P6 server is getting started but P6 application is failing to start and giving above error.
    but my p6help web application is showing Active state.
    I added below line in startWeblogic.cmd and setDomainEnv.cmd file but no use.
    set JAVA_OPTIONS=%JAVA_OPTIONS% -Dprimavera.bootstrap.home=C:\P6EPPM_1\p6\
    I tried by redeploying p6 application but still same error.
    Please help.

    Hi,
    I has set the classpath as well same as above.
    If i start managed server manually or using start_primavera.bat,  P6 application is becomeing acive and working.
    But if i start managed server using windows service, Managed server is get started, p6help is also becoming active but only p6 is failing to start.
    If i chek the log it is showing same log below,
    [Wed Oct 30 16:08:53 2013] [I] [RunJavaApp] Locating method "public static void main([]String)" in main class
    [Wed Oct 30 16:08:53 2013] [I] [RunJavaApp] Building arguments for main class
    [Wed Oct 30 16:08:53 2013] [I] [RunJavaApp] Invoking main class
    <Oct 30, 2013 4:08:54 PM IST> <Info> <Security> <BEA-090905> <Disabling CryptoJ JCE Provider self-integrity check for better startup performance. To enable this check, specify -Dweblogic.security.allowCryptoJDefaultJCEVerification=true>
    <Oct 30, 2013 4:08:54 PM IST> <Info> <Security> <BEA-090906> <Changing the default Random Number Generator in RSA CryptoJ from ECDRBG to FIPS186PRNG. To disable this change, specify -Dweblogic.security.allowCryptoJDefaultPRNG=true>
    <Oct 30, 2013 4:08:54 PM IST> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) 64-Bit Server VM Version 20.45-b01 from Sun Microsystems Inc.>
    <Oct 30, 2013 4:08:55 PM IST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 10.3.6.0  Tue Nov 15 08:52:36 PST 2011 1441050 >
    <Oct 30, 2013 4:08:56 PM IST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
    <Oct 30, 2013 4:08:56 PM IST> <Info> <WorkManager> <BEA-002900> <Initializing self-tuning thread pool>
    <Oct 30, 2013 4:08:56 PM IST> <Notice> <Log Management> <BEA-170019> <The server log file C:\Oracle\Middleware\user_projects\domains\Primavera\servers\P6\logs\P6.log is opened. All server side log events will be written to this file.>
    <Oct 30, 2013 4:08:57 PM IST> <Notice> <Security> <BEA-090082> <Security initializing using security realm myrealm.>
    <Oct 30, 2013 4:08:59 PM IST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STANDBY>
    <Oct 30, 2013 4:08:59 PM IST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
    <Oct 30, 2013 4:09:00 PM IST> <Warning> <HTTP> <BEA-101377> <Filtering class loader configuration ignored for web module p6.war of application p6>
    Oct 30, 2013 4:09:03 PM com.sun.faces.config.ConfigureListener contextInitialized
    INFO: Initializing JavaServer Faces implementation (1_2_07-b03-FCS) for context '/p6'
    - Refreshing com.primavera.bre.SystemApplicationContext@7fc4fe21: display name [com.primavera.bre.SystemApplicationContext@7fc4fe21]; startup date [Wed Oct 30 16:09:05 IST 2013]; root of context hierarchy
    - Loading XML bean definitions from class path resource [/com/primavera/pvweb/servlet/webconf.xml]
    - Bean factory for application context [com.primavera.bre.SystemApplicationContext@7fc4fe21]: org.springframework.beans.factory.support.DefaultListableBeanFactory@35f5e42b
    - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@35f5e42b: defining beans [metaConfigProvider,settingsManager,adminManager,LogMgr,performanceManager,threadPool,remoteQManager,subSystemInitializer,sqlConnectionPoolManager,registryService,tracer,mailService,configDumpHelper,autoConfigCollectionTask,proxiedUrlOpener,systemFacade,autoStarterService]; root of factory hierarchy
    System property 'primavera.bootstrap.home' not found
    <Oct 30, 2013 4:09:07 PM IST> <Warning> <HTTP> <BEA-101162> <User defined listener com.primavera.pvweb.listeners.PVContextListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registryService' defined in class path resource [/com/primavera/pvweb/servlet/webconf.xml]: Invocation of init method failed; nested exception is com.primavera.common.exceptions.InvalidBootstrapException: System property 'primavera.bootstrap.home' not found.
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registryService' defined in class path resource [/com/primavera/pvweb/servlet/webconf.xml]: Invocation of init method failed; nested exception is com.primavera.common.exceptions.InvalidBootstrapException: System property 'primavera.bootstrap.home' not found
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    Truncated. see log file for complete stacktrace
    Caused By: com.primavera.common.exceptions.InvalidBootstrapException: System property 'primavera.bootstrap.home' not found
    at com.primavera.common.BootstrapHome.get(Unknown Source)
    at com.primavera.infr.admin.MetaCfg.a(Unknown Source)
    at com.primavera.infr.admin.MetaCfg.getMetaJDBCURL(Unknown Source)
    at com.primavera.infr.srvcs.RegistryServiceImpl.init(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    Truncated. see log file for complete stacktrace

  • How can I get the the system property line.separator??

    hi all,
    the system property line.separator .
    the PrintStream's function println uses this properly for next line.. I dont want to use this function. and '\n' does not work exaclty as "the system property line.separator" works..

    System.getProperty("line.separator") oughta do it :-)

  • Can you set a global EntityResolver (via system property, or static method)

    I'm trying to set a customized EntityResolver (telling the xml parser where to look for XML schema files).
    Usually, you'd use the standard syntax - somehting like:
    SaxParser parser=new SaxParser();
    parser.parser.setEntityResolver(myResolver);
    However, I was wondering whether you can set a "global" EntityResolver, to be used as default for all parsers ?
    Maybe this can be done through some system property, or a static method somewhere in the parsing XML ?
    (BTW, I need it because I'm using some third-party API, that encapsulates a SaxParser, but won't let me access it, so I can't configure it directly).
    thanks.

    I don't think you can.
    What is possible is to set content on the folder resource itself; that would be returned instead of the page you mentioned.

  • System property in managed server

    I have a little problem with my managed server. I want to put this
    "-Dsteria.log4j.configuration=%WL_HOME%\user_domains\NesDomain\log4j.properties"
    "-Dsteria.log4j.interval=30000", in the start script to the managed server, but
    I can't get it to work. I have tried to put it in the startWLS.cmd, startNodeManager.cmd
    and even in the startWLS of my admin server, but nothing helps.
    When I make a System.getProperty("steria.log4j.configuration");
    null is returned.

    -Dmyarg=superduper
    You can view this in the weblogic.log:
    BEA-141034 Jun 26, 2003 8:06:20 AM PDT Info Management
    Java system property: myarg = superduper.
    cheers
    mbg
    "Kris" <[email protected]> wrote in message
    news:3efaa4a4$[email protected]..
    >
    I am using the nodeManager to start the servers, I also tryed to put themas you
    say in the arguments, but I am not sure about the syntax to use, can youwrite
    me an ex. thanks
    '"Mark Griffith" <[email protected]> wrote:
    What version of WLS?
    How are you starting the server?
    If you are starting the server via the startManagedServer.cmd then
    putting
    it in the start script is the way.
    IF you are starting the server via the node manager then you need to
    specify
    these args in the console under
    mydomain --> Servers --> "myserver"
    Configuration Tab ==> RemoteStart Tab, the "Arguments" field.
    Cheers
    mbg
    "Kris" <[email protected]> wrote in message
    news:3ef9ccbf$[email protected]..
    I have a little problem with my managed server. I want to put this
    "-Dsteria.log4j.configuration=%WL_HOME%\user_domains\NesDomain\log4j.propert
    ies"
    "-Dsteria.log4j.interval=30000", in the start script to the managedserver, but
    I can't get it to work. I have tried to put it in the startWLS.cmd,startNodeManager.cmd
    and even in the startWLS of my admin server, but nothing helps.
    When I make a System.getProperty("steria.log4j.configuration");
    null is returned.

  • Pass dynamic Command line arguments

    Hi,
    I tried to pass dynamic command line argument to Web start using the method :
    "javaws URL -D foo -D bar"
    as explained in the "Unofficial JWS/JNLP FAQ" that " You can pass your own system properties to your app using -D switch ....", but I got the following error at the start;
    error occurred while launching/running the application.
    Category: Invalid Argument error
    Too many arguments supplied: {http://...URL/my.jnlp, -Did=123 }
    p.s. I already added the"<property name='' value=''/> in the <resourse>, and modified the main class to get the parameter using System. getProperty();
    Did anyone try to this method before? What's wrong of this?
    Thanks in advance for your help.

    Thanks.
    here below is the jnlp file:
    <jnlp spec="1.0+" href="$$name" codebase="$$codebase">
    <information>
    <title>GUI Application</title>
    <vendor>PS</vendor>
    <description>PS GUI WebStart Version</description>
    <icon href="logo.jpg" />
    <offline-allowed />
    </information>
    <resources>
    <j2se version="1.3" />
    <jar href="lib/gui.jar" />
    <property name="id" value="zbc" />
    <jar href="lib/classes12.zip" />
    <jar href="lib/j2ee.jar" />
    <jar href="lib/jaas.jar" />
    <jar href="lib/jce1_2_1.jar" />
    <jar href="lib/jdom.jar" />
    <jar href="lib/xerces.jar" />
    <jar href="lib/local_policy.jar" />
    <jar href="lib/log4j.jar" />
    <jar href="lib/orion.jar" />
    <jar href="lib/sunjce_provider.jar" />
    <jar href="lib/US_export_policy.jar" />
    </resources>
    <security>
    <all-permissions />
    </security>
    <application-desc main-class="GUIFrame">
    </application-desc>
    and in the main class "GUIFrame", i use System.getProperty("id") t get the parameter, if I hardcode the value of the "id" in this jnlp file and use javaws URL, everything's fine, but not the "javaws URL -Did=value" which will return the error as mentioned.
    Thanks again for your help.

  • How to read -Dname=value pair command line arguments

    Hi
    iam running one program called report.java as given below
    compile:
    javac report.java
    run:
    java report -Djava.path=home/arao/jaava1.5/bin
    my problem is how to read name and value pair given in command line argument.
    System.getProperty("java.path");//not working can anybody help how to read name and value
    pair of -D option

    If you put that string after the name of the class you are running, then it's a command line parameter. Your main() method can look at args[0] to see it. However it would be better if you just put it before the name of the class, where it's supposed to go if you want it to be treated as a system property.

  • How to hide the command line arguments from solaris process

    Hi All,
    When I execute a JAR application from a java file using the Runtime.getRuntime, the command line arguments (user ID and Password details) which I passed for executing the application displayed on Solaris process (ps -ef).
    Could anybody please help me, how can I hide either the process or the command line arguments from the Solaris process?
    I cannot pass any asterix or any special character in place of password, because the executing application doesn't have any functionality to retreive the password which send as asterix characters.
    Please help me
    SumodeV

    Thanks for all the response.
    I have created a design and implement the functionality which executes the JAR application in Solaris environment without showing any details in the process details.
    I have used the Java Reflection method, which invokes the JAR application. I am sharing the details here for all those who looking for it.
    1, Inside the Customer application [Jar File is running for it], collect the necessary session details [Using System.get property method]
    2, Create an independent Java file, which should be used to invoke the JAR application
    3, Create the ProcessBuilder object and use a command - execute the Java file [a wrapper code] using normal Java command
    4, Pass the necessary session details to the ProcessBuilder using the environment() function.
    5. Collect the environment values in the independent Java file (Which was invoked by ProcessBuilder) and set details for its environment using System.setProperty.
    6, Use reflection technique to invoke the JAR plugin [which you want to run]. You can use the standard Java functionality to read the MANIFEST file of JAR and load the main class using URLClassLoader.
    7, Invoke the main method of the JAR file, which run the JAR application in Solaris window
    This solution will make sure that the process cannot display any session details in the Solaris Environment.
    Note: Use String[] array while create the command. Otherwise the JAR application cannot pop-up.
    Regards
    Sumode

  • Passing dynamic System property to applicaiton

    Is it possible to pass dynamic system property from the command line to the application in javawebstart. So that my application can get it using System.getProperty() method.
    Thanks in Advance,
    Sarangan

    Hi,
    Thanks. But its not possible for us to move to SE 6. Right now we are in JRE 1.5. Is there any other way to pass mulitple/dynamic arguments to the Applicaiton. We will be using only the javaws command line only to invoke the remote application by passing the url(jnlp_url). So we need to pass mulitiple command line arguments to the application through javaws.
    Sarangan

  • Burrito - can't set 'command line arguments' (mobile)

    Hi all,
    The option to set command line arguments in the "Run/Debug Settings" - "Launch Configurations" dialog disappears when a new "Flex Mobile AIR Project" is created.
    I am developing APKs that are launched via Intents from other Android apps; setting arguments for testing in the IDE would improve the workflow that now requires me to deploy to the device for testing. Is there a workaround for this?
    Thanks,

    Put the command into a file with execute permissions, including whatever command-line arguments you want. For instance, the file might contain the following:
    #! /bin/bash
    xpdf -g 1200x900 -z width -cont "$1"
    In Firefox preferences, under "Applications," locate the appropriate Content Type and in the Action menu, select "Use other..." and then locate the executable file you just created and select it.
    In UNIX-type operating systems at least, available options to the command can be found using the "man" command (e.g. "man xpdf" for the example above).

Maybe you are looking for

  • Can I use my iMac 2009 as an external monitor for a MacBook Pro

    I will soon be getting a new MacBook Pro with Retina display. It has an HDMI port. My current iMac 21.5" late 2009 model seems to have a port with what looks like a little monitor symbol, next to the firewire port. And the specs say: Graphics and vid

  • Problem with the progress line in MS Project

    Hi there, I have a question about the progress line in MS Project.  My boss asked me to see how far we were with the work, so I inserted the column '% Complete' and then the progress line. Now my boss has a problem with the layout and I don't know h

  • Display File Extension in iPhoto?

    I've just started to use iphoto.  In the thumbnail view of an event (or for that matter, anytime I'm viewing a display of thumbnails), I would like iphoto to display file name and file extension.  It's not doing that and I can't see a setting in ipho

  • Information Steward Scorecard

    I am running BO 4.0 and I have created a Information Steward project with a scorecard. I was wondering if there was a way to directly link to this scorecard or a way to post it to an SAP Portal iview?

  • PPTP VPN Setup

    So Lion only has a GUI to configure L2TP but I want to use PPTP because it's easier to get to working thru NAT. I found this article to get me going: http://support.apple.com/kb/HT4748 Is there anything else that needs to be done? Will I login with m