SCJP System.getProperty()

I am having problem with a scjp question:
public class vv{
     public static void main(String[] args){
          String myProp = System.getProperty("prop.custom");
          System.out.println(myProp);
suppose it can complie if I use:
System.getProperty("prop.custom");
but there is java.lang.ClassNotFoundException: prop.custom=gobstopper
What's wrong?

Welcome to the Sun forums.
crunchor wrote:
..but there is java.lang.ClassNotFoundException: prop.custom=gobstopperHuhh?
public class vv{
     public static void main(String[] args){
          String myProp = System.getProperty("prop.custom");
          System.out.println(myProp);
andrew@pc1:/media/disk/proj$ javac vv.java
andrew@pc1:/media/disk/proj$ java vv
null
andrew@pc1:/media/disk/proj$
What's wrong?Which brings me back to - huhh?
BTW - Please use code tags when posting code, code snippets, HTML/XML or input/output. The code tags protect the indentation and formatting of the sample. To use the code tags, select (highlight) the sample and click the CODE button.

Similar Messages

  • Problem with System.getProperty( "com.stc.application.dataroot" ) in JCAPS6

    Hello everybody,
    I'm using JCAPS 6 but I have to follow a guideline of projects implemented with JCAPS 5.1.3.
    The project for example, has written for the logs-directory in method user initialize this code:
    // JCAPS uses JVM version 1.5
    logger.info( "--- BEGIN ------ JCAPS userInitialize" );
    String currRoot = System.getProperty( "com.stc.application.dataroot" );
    String log4j_props = currRoot + "/../../NameDirectory/" + collabContext.getProjectPath() + "/" +
    collabContext.getCollaborationName() + "_log4j.properties";
    With JCAPS 6 I don't know how to substitute "System.getProperty( "com.stc.application.dataroot" );" because with it don't function.
    Somebody can help me?
    Thanx!
    Fabrizio

    This is the correct code:
    // JCAPS uses JVM version 1.5
    logger.info( "--- BEGIN ------ JCAPS userInitialize" );
    String currRoot = System.getProperty( "com.stc.application.dataroot" );
    String log4j_props = currRoot + "/../../NoemaLife/" + collabContext.getProjectPath() + "/" + collabContext.getCollaborationName() + "_log4j.properties";
    but I have the same problem...

  • System.getProperty("user.name") not working without /etc/passwd, CentOS 4.3

    Dear all,
    I'm having trouble getting the system property user.name (which we need in our ant scripts) on our CentOS box. :(
    When running the program below thru
    java dumpproperties2
    it prints "user.name='?'" on our CentOS 4.3. On win32 it works. It turns out that if you add the account corresponding to the EUID to /etc/passwd it works correctly. However, we don't use passwd authentication but an enterprise wide LDAP-system. Our /etc/nsswitch.conf says:
    passwd: files ldap
    One work around is to replace the java executable with a script that does
    /path/to/jdk/bin/java -Duser.name=$USER -Duser.home=$HOME $@
    Used jdk is j2se 1.5.0_13 Linux 32-bit.
    Some questions for the experts:
    1) Is there any other way?
    2) Is it a known issue that Linux versions of the jdk just looks in /etc/passwd to map uid to user name (and home dir) instead of doing what the rest of the system, like whoami, does? I haven't found anything in either the readme or installation instructions, nor in the bug db.
    Br, Jesper Tr�g�rdh
    public class dumpproperties2 {
        public static void main(String[] args) {
         String s = System.getProperty("user.name");
         System.out.println("user.name='" + s + "'");
    }

    Does this work?
    //public final class System
    public static String getenv(String name)Then you can access the USER environment from inside Java.

  • System.getProperty("user.dir") returns "/home/user" on Linux

    Has anyone else had the error when launching a jar from Linux (just by clicking it), System.getProperty("user.dir") returns the "/home/user" (or "~") value instead of the folder that the jar is in? Essentially, it returns "user.home" instead of "user.dir".
    This does not happen when I start the application from command line.
    (I know its not swing, but I wasn't sure where to post it)
    Is this just a simple Linux setting that isn't enabled by default? Ubuntu already made the file association after using apt-get to install Java 6.
    Cheers.
    -FBL

    Because, semmingly, the command is being set off as
    java -jar relative/pat/to/file.jarwhen you double click it, rather than
    cd relative/path/to
    java -jar file.jarIf you don't like this, I would say to find a Linux, preferably Ubuntu, forum and ask there if it is possible to change that handling, and if not, request that a cahnge be made to the code to change that handling. But, in any case, I doubt you are going to get an answer here about it.

  • Can we write %System.getProperty("CONFIG_MODE");% this stmt in EL or jstl

    Hi everyone,
    Can we write below statement in EL or jstl instead of using Scriplet.
    <%System.getProperty("CONFIG_MODE");%>
    Thanks,
    Nihar.T

    getting a system property is too much on the business logic side. You could create a bean that returns the system property as a member, like:
    public class PropertyBean
    public String getConfigMode()
      return System.getProperty("CONFIG_MODE");
    }then simply use EL in your JSP(s) to get the value from that bean. Of course you could just make the getConfigMode() method part of an existing bean you are using.

  • Enums for System.getProperty(...) method in Java API?

    Just had a thought today as a result of a colleaugue mis-spelling "file.separator" in a System.getProperty() call:
    How about an enum for the above method (e.g. SystemProperty) that has all the known properties and the String method for any prop not included in the enum?
    Am I being too greedy or pedantic about type-safety?
    Appreciate your feedback.
    Cheers,
    Ali
    Edited by: user7627452 on 30-Apr-2012 19:09

    Yes. The whole idea is that anybody can add their own. As opposed to an API.

  • System.getProperty("user.region") in JDK version 1.3 vrs. 1.4

    Hi guys,
    I wonder why, when I set the following instruction to detect the regional settings, I got different results using 1.3.1 vrs. 1.4.1?
    String slRegion = System.getProperty("user.region");
    If I use 1.3.1 then I got the right result, but if I use 1.4.1 I got a null value.
    I need to use JDK 1.4.1, that's why I'm interested in getting the answer.
    TIA.

    As I want to know the 2 letters of the countries, such as:
    IN_USA = "US";
    ES_MEXICO = "MX";
    ES_ARGENTINA = "AR";
    ES_BOLIVIA = "BO";
    ES_CHILE = "CL";
    ES_COLOMBIA = "CO";
    ES_COSTARICA = "CR";
    ES_REPDOMINIC = "DO";
    ES_ECUADOR = "EC";
    ES_SALVADOR = "SV";
    What would it be the syntaxis (line code) to get this info?
    I appreciate your help

  • [svn:bz-trunk] 20505: Bug: Watson #2818669 - AbstractAmfInput uses System. getProperty in Constructor leading to AccessControlException when using in Applet

    Revision: 20505
    Revision: 20505
    Author:   [email protected]
    Date:     2011-03-01 07:31:55 -0800 (Tue, 01 Mar 2011)
    Log Message:
    Bug: Watson #2818669 - AbstractAmfInput uses System.getProperty in Constructor leading to AccessControlException when using in Applet
    QA: Yes
    Doc: No
    Checkintests: Didn't run - the change was to wrap the System.getProperty in a try/catch that would have caused the SecurityException, so no real functionality change that could affect the check-in tests.
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/AbstractAmfInput.java

  • Java 7 u45 System.getProperty returns null

    After upgrade to u45, our web launch application stopped working. it failed at System.getProperty("myproperty").
    "myproperty" is defined as a
    <resources>       
    <j2se version="1.6+" initial-heap-size="64m" max-heap-size="256m"/>
           <jar href="nms_wsclient.jar" download="eager" main="true"/>
           <jar href="commons-httpclient.jar" download="eager"/>      
          <jar href="commons-codec.jar" download="eager"/>       
          <jar href="commons-logging.jar" download="eager"/>       
          <jar href="log4j.jar" download="eager"/>       
          <property name="myproperty"   value="http://138.120.128.94:8085/"/>
        </resources>
    with older version java ,System.getProperty("myproperty") works fine to return the value, but with u45 it returned null.
    Does anyone have the same problem? any idea how to fix it or work around it?
    Thanks,
    Zhongyao

    So did you succeed with the jnlp template ?
    After frustrating hours of that information useless JNLPSigningException trial & error, It seems that as :
    1. You can't make the j2se version variable
    2. You can't have your own variable property/values
    I've opened a bug report...
    The documentation is atrocious, with a vague "we reserve the right to blacklist variable elements, but we will never say which ones".
    The JNLP example in the various example is a joke - Its a hello world jnlp, not a real world one.
    The JNLPSigningException must have been written my the same guys at Microsoft that did the "An Unknown Error As Occurred".
    I've had to clear the cache at every test, seems that the JNLP Template check didn't get the new updated JNLP from the web server.
    /rant over
    I think I'll try to bypass that JNLP property mess and get javaws to download my own "jnlp name".xml.config...

  • Applet, System.getProperty question

    I am trying to develop a simple applet that would capture the NT user name with System.getProperty("user.name"). This will not work with servlet because it will only return the server user.name. With applets running on clients systems, I was hoping that this will work. My applet has only 1 button and 1 text field. It runs fine in a debug mode in Forte 2.0. It generates an error msg when I run in in Forte. It doesn't do anything if I add the class to a html file. Am I on the right track here or what do I need to do to get this to work?
    private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
    String login = System.getProperty("user.name");
    textField1.setText(login);
    This works in a debug mode in Forte, but fails when I run it. This is the error message:
    Exception occurred during event dispatching:
    java.security.AccessControlException: access denied (java.util.PropertyPermission user.name read)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:272)
    at java.security.AccessController.checkPermission(AccessController.java:399)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
    at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1278)
    at java.lang.System.getProperty(System.java:560)
    at LoginApplet.button1ActionPerformed(LoginApplet.java:40)
    at LoginApplet.access$0(LoginApplet.java:39)
    at LoginApplet$1.actionPerformed(LoginApplet.java:20)
    at java.awt.Button.processActionEvent(Button.java:329)
    at java.awt.Button.processEvent(Button.java:302)
    at java.awt.Component.dispatchEventImpl(Component.java:2595)
    at java.awt.Component.dispatchEvent(Component.java:2499)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
    at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)

    Hi,
    As you can see you received a Security exception, for a good reason. If you could access a username and/or password then your computer could be compromised. Anyone could then write an unseen applet embedded in their web page that gathers username/password for any computer that requests the web page. The security manager on that specific PC (or web browser) would have to be modified specifically to allow this sort of access, which is not advised because then anyone else with this type of applet could get the same information that you are attempting to get (if you request a web page on another site with that applet requesting you system information).
    Hopefully this helps.

  • System.getproperty("Var Name") gives null in RedHatLinux5

    Please provide some solution for this strange problem. I am able to get the system property value from terminal but when I use System.getproperty() I am getting null.
    Ex:
    echo $client
    ans: /home/naveen/client/classes
    from java program
    System.getproperty("client"); it gives null

    use getenv(), instead of getProperty()

  • Getting cell id in java me using System.getProperty

    Hi all
    I wish to get the cell id of the cell (I know it had been asked for more than a million times) that my nokia phone is currently connected to with the api listed here
    [http://wiki.forum.nokia.com/index.php/CS000947_-_Getting_Cell_ID_in_Java_ME|http://wiki.forum.nokia.com/index.php/CS000947_-_Getting_Cell_ID_in_Java_ME]
    As stated,
    System.getProperty("com.nokia.mid.cellid") works on S60 3rd Ed
    System.getProperty("Cell-ID") works on S40 3rd Ed
    However, I am unable to do so on N82, anyone have any idea why is that so?
    Or is there any kind soul with N95 can tell me whether it works on N95?

    yes.. I saw that thread before I posted this.. but the piece of code mentioned in the thread does not make use of the api listed in the wiki right?
    In fact, I'm not very clear as to what that mentioned code is doing.
    Moreover, my point would be, how come the api is listed in the wiki in that case.. that is, if it does not work.. :/

  • Alternative to System.getProperty("microedition.hostname")

    Hey is there any other alternative for 'System.getProperty("microedition.hostname")' to get the ip address of the device running the j2me midlet ??
    When you run the midlet on the emulator, System.getProperty("microedition.hostname") returns the PC's Name, but on a Nokia series 40(3rd E) device, it returns null.
    So is there an alternative to this to select the device's ip address ?

    First this is a pretty specific question which applies to a specific device rather than to reflection/reference. You might want to look for a forum that addresses the specific device.
    Second, you can print the system properties normally. Whether you can do that on the device depends on the device. If you succeed you might find an alternative.
    Third normally one uses the java.net.IpAddress to get a device IP. Does that not work for that device?

  • System.getProperty("user.home") is giving diferent results on diff versions

    I am working on windows 2000. When I try to get user.home using System.getProperty it gives me c:\documents and settings\my name.
    But the same things when tried on a windows 2003 server tries to look in c:documents and settings\default directory. Why is this?
    Please help.....

    In XP, the environment variable USERPROFILE is set to C:\Documents and Settings\<username>, and that value is picked up for user.home. Since the "user's home directory" varies by os, there will be variations. 98 is different than Linux than XP, etc.

  • System.getProperty("os.name")

    Hey
    Can any one tell me what does the return string value for System.getProperty("os.name") on unix platform. i am asking this since i dont have unix installed on my system to test it.
    Tkx in advance

    It comes back w/ the basic flavor.
    ie
    AIX -> AIX
    Linux -> Linux
    HP-UX -> HP-UX
    Solaris -> Solaris

Maybe you are looking for

  • Keynote 6.0 crashes after 2 sec / Mavericks

    Hey Guys, I just installed keynote through the appstore. When i open the application, it quits after about 2 seconds. In Guest mode it is just fine. There are no Powerpoint or Keynotes file in my dropbox. Standard Fonts are restored in Font Book. hop

  • How to boot from .iso in mac os x 10.7?

    Hey,  I have a backtrack3 dvd that i use to be able to boot to in snow leapord, however in lion I am unable to. Anyone know a workaround for this?  Also having the ablility to boot from a .iso that is mountable on my desktop and running it (backtrack

  • Copying condition records in SD

    Hi, We are in SAP 4.7. In condition type VA00, I have about 100 condition records in sales orgn 0001 for material 0001. I would like to copy all these 100 condition records within the same condition type VA00, but into a different sales orgn 0002 for

  • Roadmap steps  are not visible after patching

    Hi , After upgrading or patching ,roadmap steps are not visible in my application. i have used several road maps in my application? what is the reason for this? Regards, Lakshmi.

  • OS X Safari and Hotmail Certificate Problem

    Hello Apple discussions,I Am having problems accessing part of a microsoft hotmail account which explains below I Have a problem with my hotmail Web account Using OS X 10.6.4 Safari 5.0 when I Try adding another email account to my hotmail account wh