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.

Similar Messages

  • [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

  • 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.

  • 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?

  • Applet, system properties

    Im using a signed applet. Is there a way to tell whether the applet is running on win98 or win2k? The applet needs to know what OS it is run on.

    System.getProperty("os.name");

  • 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.

  • 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.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.

  • Applet in Netscape question.

    Hi, Applet in Netscape question.
    When an applet is run by Explorer everything is OK when trying to run with Netscape (7.1) nothing happening
    What is wrong here ???
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    WIDTH = "730" HEIGHT = "260"
    codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4-
    windows-i586.cab#Version=1,3,0,0">
    <PARAM NAME = CODE VALUE = "Xaaa.class" MAYSCRIPT>
    <PARAM NAME = ARCHIVE VALUE = "Ybbb.jar">
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">
    <PARAM NAME="scriptable" VALUE="false">
    <PARAM name="progressbar" value="true">
    </OBJECT>
    Thank you in advance !

    Dear Experts.
    Reading through previous Forum similar questions, I changed the code (down below)
    Now I receive the message:
    Click here to get the plugin
    This is encouraging because before Netscape ignored the applet completely ...
    However I already have plugin version 1.4.2_03 installed (and recognized by Explorer)
    The question is still why the applet is not working with Netscape ?
    Thank you in advance for your help?
    <html>
    <body>
    <!-- HTML CONVERTER -->
    <object
    classid =" clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    codebase =" http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0"
    width = 730 height = 260 >
    <param name = CODE value ="Xaaa.class" >
    <param name = ARCHIVE value ="Ybbb.jar" >
    <param name =" type" value =" application/x-java-applet;jpi-version=1.4">
    <param name =" scriptable" value =" false">
    <param name="progressbar" value="true">
    <comment> </comment>
    <embed
    type =" application/x-java-applet;version=1.4"
    code =" Xaaa.class"
    archive ="Ybbb.jar"
    width = 730
    height =260
    scriptable = false
    pluginspage =" http://java.sun.com/products/plugin/index.html#download">
    <noembed> alt="Your browser understands the <APPLET>
    tag but isn't running the applet, for some reason."
    Your browser is completely ignoring the <APPLET>
    tag! </noembed> </embed> </object>
    <!--"END_CONVERTED_APPLET"-->
    </html>
    </body>

  • 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

  • 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...

  • 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.. :/

Maybe you are looking for

  • USB Ethernet no longer recognized?

    Hi After a reinstall of Leopard to remove languages and the sorts I had a slim installation on my air and everything was running nicely. Now however the USB Ethernet is not being recognized at all .. I have checked with the superdrive and no problems

  • Office Jet Pro 8500 Offline Will Not Print

    Please help! I cannot get my Officejet Pro 8500 Wireless to print. I have had this printer since early September and have not gotten it to work wirelessly on my laptop with the exception of using the USB configuration. I have a Dell laptop that I had

  • Unable to upload files via admin & FTP

    I've been trying to upload files to this site, but it keeps on bringing errors. It worked fine 20 minutes ago. Now the FTP doesn't upload and the Admin File Manager brings back errors on upload as well. Anyone know what's going on? The system status

  • USB doesn't work on my Macbook Pro

    Hey guys ! So I very like taking pictures and stuffs.. so I decide to buy a Macbook Pro ( 10.7.5 ) to make my picture more beautiful But it's not turn easy like I thought. All the usb I tried didn't work on my macbook ! I don't know why but just my H

  • CSS not being accessed on certain Web sites

    When I access www.thebytestopshere.com (my Web site), none of the text is rendered according to the rules set forth in the .css file. It does render correctly if I access the files from my C:\ drive. Everything renders properly in Internet Explorer,