Java.util.pref.Preferences

Hello Sir,
Is java.util.pref.Preferences class support property file?
Thanks for advance
bala

Read the API for Preferences.
Typical implementations include flat files, OS-specific registries, directory servers and SQL databases. The user of this class needn't be concerned with details of the backing store.
Does that answer your question?
db

Similar Messages

  • How to create a node in java.util.prefs.Preferences  -- Need Help !!

    Hi All
    I want to know the way of implementing a Node using java.util.prefs.Preferences , and need to store a value.
    Your Help wil be greatly appreciated
    best Regards
    Madumm

    http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html

  • Java.utils.prefs.Preferences API throws exception on Mac, not Windows

    This is a Mac-specific problem. Is it a bug, or am I misusing the java.utils.prefs.Preferences API?
    The Preferences flush() API call always throws a BackingStoreException if a system tree preferences root has been read. The system tree has not been modified or written to, but the flush() call is nevertheless throwing an exception. This occurs when running as a normal user without the ability to write to /Library/Preferences.
    See sample code below. Note that I only want to read the system prefs tree. The user tree write flush fails. If the system tree node is not created, the user flush() succeeds.
    Steps to Reproduce
    Delete any existing Java prefs files:
    ~/Library/Preferences/com.apple.java.util.prefs.plist
    ~/Library/Preferences/com.mycompany.prefstest
    /Library/Preferences/com.apple.java.util.prefs.plist
    /Library/Preferences/com.mycompany.prefstest
    Run the following Java code:
    package com.mycompany.prefstest;
    import java.util.prefs.BackingStoreException;
    import java.util.prefs.Preferences;
    public class PrefsTest {
          * @param args
         public static void main(String[] args) {
              String strKey1 = "com/mycompany/prefstest/one/two/three/four/key1";
              Preferences systemRoot = Preferences.systemRoot();
              Preferences userRoot = Preferences.userRoot();
              // Get a value for user prefs.
              String value1 = userRoot.get(strKey1, "missing");
              // Fall back to system prefs if it is not defined.
              if (value1.equals("missing"))
                   value1 = systemRoot.get(strKey1, "missing");
              System.out.println("key1 --> " + value1);
              // If still not defined, set a user-specific value
              if (value1.equals("missing"))
                   userRoot.put(strKey1, "value1");
                   try {
                        userRoot.flush();
                        System.out.println("flushed prefs successfully");
                   catch (BackingStoreException e)
                        System.out.println("Exception: " + e.toString());
    Expected Results
    Should produce the output:
    key --> missing
    flushed prefs successfully
    Actual Results
    Console output is
    key --> missing
    Exception: java.util.prefs.BackingStoreException: Synchronization failed for node '/'
    Notes
    $ java -version
    java version "1.6.0_29"
    Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11D50b)
    Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
    also tested with:
    java version "1.7.0_04-ea"
    Java(TM) SE Runtime Environment (build 1.7.0_04-ea-b16)
    Java HotSpot(TM) 64-Bit Server VM (build 23.0-b17, mixed mode)
    Mac OS X 10.7.3.
    The "Expected Results" are correctly obtained running the same code on MS-Windows.
    Running the jar as sudo works (with write access to /Library/Preferences), as expected.

    Just for fun, try a key without slashes in it (but for example dots if you must use such a long key).
    I say that because a quick Google search points out that Apple stores the preferences in a file hierarchy in the user home folder. I can already see how using keys which look like a file path are going to cause nuclear reactors to meltdown...

  • How can I create an instance of "java.util.prefs.WindowsPreferences"?

    Hi All,
    I was trying to find out a way to access the Windows Registry to add soome keys and and later add a string.
    I found WindowsPreferences might be useful in the above mentioned context.
    I was trying to create an instance of it, but when I import the class, it says it is invisible.
    Can anyone let me know how to instantiate this class.
    Note:- Under the same package "java.util.prefs" we have another class "Preferences", Iam able to import this one and use it in my code.
    Thank You.
    Regards,
    Suman.H

    It's true that Preferences uses the Registry on Windows systems, that does not mean you can use it as a Registry API. The only part of the Registry you can access are those branches that are set aside for java.util.prefs: HKLM\Software\JavaSoft\Prefs and HKCU\Software\JavaSoft\Prefs. IF you need to access other parts of the Registry, you'll need to use JNI or a separate Windows Registry library.

  • Where is javax.prefs.Preferences

    Hi,
    Could you tell me which jar I need to add to the classpath to get
    javax.prefs.Preferences? and where can I download it?
    Thanks

    If you mean, "Where is the java.util.prefs package?" it is part of J2SE as of version 1.4.0.
    Shaun

  • Java.util.MissingResourceException - A Bug?

    Hi all,
    I think there maybe an bug with the plugin /deploy.jar the JRE 1.5.0_06.
    There is an exception at the end when my signed applet is trying to install an extension for the JRE, it seems to be caused by
    java.util.MissingResourceException: Can't find resource for bundle com.sun.deploy.resources.Deployment, key security.dialog.buttonYes.acceleratorKey
    the resources are defined in com.sun.deploy.resources.Deployment.java and it does not contain that key.
    Is this a bug?
    This happens in both Internet explorer and mozilla/firefox.
    Thanks for any help,
    Ashley
    Java Plug-in 1.5.0_06
    Using JRE version 1.5.0_06 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\hayesac
    network: Loading user-defined proxy configuration ...
    network: Done.
    network: Loading proxy configuration from Netscape Navigator ...
    network: Reading user preference file from C:\DOCUMENTS AND SETTINGS\HAYESAC\APPLICATION DATA\Mozilla\Profiles\default\c8ovvpcr.slt\prefs.js
    network: network.proxy.ftp=192.168.50.8
    network: network.proxy.ftp_port=8080
    network: network.proxy.gopher=192.168.50.8
    network: network.proxy.gopher_port=8080
    network: network.proxy.http=192.168.50.8
    network: network.proxy.http_port=8080
    network: network.proxy.socks=192.168.50.8
    network: network.proxy.socks_port=8080
    network: network.proxy.ssl=192.168.50.8
    network: network.proxy.ssl_port=8080
    network: Proxy enable: 1
    network: Done.
    network: Loading browser proxy configuration ...
    network: Done.
    network: Proxy Configuration: Browser Proxy Configuration
    basic: Cache is enabled
    basic: Location: C:\Documents and Settings\hayesac\Application Data\Sun\Java\Deployment\cache\javapi\v1.0
    basic: Maximum size: unlimited
    basic: Compression level: 0
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    p: reload proxy configuration
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    basic: Registered modality listener
    security: Accessing keys and certificate in Mozilla user profile: C:\DOCUMENTS AND SETTINGS\HAYESAC\APPLICATION DATA\Mozilla\Profiles\default\c8ovvpcr.slt
    security: JSS package is not found
    security: JSS is not configured
    basic: Referencing classloader: sun.plugin.ClassLoaderInfo@480457, refcount=1
    basic: Added progress listener: sun.plugin.util.GrayBoxPainter@6b97fd
    basic: Loading applet ...
    basic: Initializing applet ...
    basic: Starting applet ...
    network: Connecting [manually removed] with proxy=DIRECT
    security: Loading Root CA certificates from C:\PROGRA~1\Java\JRE15~1.0_0\lib\security\cacerts
    security: Loaded Root CA certificates from C:\PROGRA~1\Java\JRE15~1.0_0\lib\security\cacerts
    security: Loading SSL Root CA certificates from C:\PROGRA~1\Java\JRE15~1.0_0\lib\security\cacerts
    security: Loaded SSL Root CA certificates from C:\PROGRA~1\Java\JRE15~1.0_0\lib\security\cacerts
    security: Loading certificates from Deployment session certificate store
    security: Loaded certificates from Deployment session certificate store
    security: Checking if certificate is in Deployment session certificate store
    security: Checking if SSL certificate is in Deployment permanent certificate store
    security: Check if certificate can be verified using certificates in Root CA certificate store
    security: Certificate to be verified:
    [certificate trace stuff manually removed]
    liveconnect: JavaScript: UniversalJavaPermission enabled
    basic: Stopping applet ...
    basic: Removed progress listener: sun.plugin.util.GrayBoxPainter@6b97fd
    basic: Finding information ...
    basic: Releasing classloader: sun.plugin.ClassLoaderInfo@480457, refcount=0
    basic: Caching classloader: sun.plugin.ClassLoaderInfo@480457
    basic: Current classloader cache size: 1
    basic: Done ...
    basic: Joining applet thread ...
    liveconnect: JavaScript: UniversalBrowserRead enabled
    liveconnect: JavaScript: UniversalJavaPermission enabled
    basic: Destroying applet ...
    basic: Disposing applet ...
    basic: Quiting applet ...
    basic: Joined applet thread ...
    basic: Unregistered modality listener
    liveconnect: JavaScript: UniversalBrowserRead enabled
    liveconnect: JavaScript: UniversalJavaPermission enabled
    liveconnect: JavaScript: UniversalBrowserRead enabled
    liveconnect: JavaScript: UniversalJavaPermission enabled
    basic: Registered modality listener
    basic: Referencing classloader: sun.plugin.ClassLoaderInfo@288051, refcount=1
    basic: Added progress listener: sun.plugin.util.GrayBoxPainter@90cb03
    basic: Loading applet ...
    basic: Initializing applet ...
    basic: Starting applet ...
    basic: httpCompression = true
    network: Connecting [manually removed]
    security: Loading certificates from Deployment session certificate store
    security: Loaded certificates from Deployment session certificate store
    security: Checking if certificate is in Deployment session certificate store
    network: Connecting https://[manually removed]
    basic: Downloading https://[manually removed]
    basic: encoding = null for [manually removed]
    basic: Cached file name: [manually removed]
    extensions: Installing optional package Extension : title(null), name([manually removed]), spec vendor(Macalla Software), spec version(3.6.3), impl vendor(Macalla Software), impl vendor id(com.macalla), impl version(3.6.3), impl url([manually removed])
    java.util.MissingResourceException: Can't find resource for bundle com.sun.deploy.resources.Deployment, key security.dialog.buttonYes.acceleratorKey
    at java.util.ResourceBundle.getObject(Unknown Source)
    at com.sun.deploy.resources.ResourceManager.getAcceleratorKey(Unknown Source)
    at com.sun.deploy.util.DialogFactory.showDownloadDialogImpl(Unknown Source)
    at com.sun.deploy.util.DialogFactory.access$200(Unknown Source)
    at com.sun.deploy.util.DialogFactory$4.execute(Unknown Source)
    at sun.plugin.util.PluginSysUtil$SysExecutionThread.run(Unknown Source)
    extensions: Optional package download not granted by user
    sun.misc.ExtensionInstallationException: User denied installation of [manually removed]
    at sun.plugin.extension.ExtensionInstallationImpl$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.plugin.extension.ExtensionInstallationImpl.installExtension(Unknown Source)
    at sun.misc.ExtensionDependency.installExtension(Unknown Source)
    at sun.misc.ExtensionDependency.checkExtension(Unknown Source)
    at sun.misc.ExtensionDependency.checkExtensions(Unknown Source)
    at sun.misc.ExtensionDependency.checkExtensionsDependencies(Unknown Source)
    at sun.misc.URLClassPath$JarLoader.parseExtensionsDependencies(Unknown Source)
    at sun.misc.URLClassPath$JarLoader.getClassPath(Unknown Source)
    at sun.misc.URLClassPath.getLoader(Unknown Source)
    at sun.misc.URLClassPath.getResource(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at sun.applet.AppletClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadCode(Unknown Source)
    at sun.applet.AppletPanel.createApplet(Unknown Source)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(Unknown Source)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    basic: Modality pushed
    basic: Modality popped
    extensions: Optional package installation failed.
    security: Loading certificates from Deployment session certificate store

    Guys,
    i am having almost the same problem with my signed applet, it was working on all previous jres, now it crashes when trying to download imageio, giving the error: sun.misc.ExtensionInstallationException: User denied installation of...
    Is this the same bug? is it really a bug?
    besides, Rita, you mentioned filing it as a bug, but i cannot find it in the bug database
    Thanks guys,
    Best,
    Mohammad

  • Java.util.logging: write to one log file from many application (classes)

    I have a menuapp to launch many applications, all running in same JVM and i want to add logging information to them, using java.util.logging.
    Intention is to redirect the logginginfo to a specific file within the menuapp. Then i want all logging from all applications written in same file. Finally, if needed (but i don't think it is), i will include code to write logging to specific file per app (class). The latter is probably not neccessary because there are tools to analyse the logging-files and allow to select filters on specific classes only.
    The applications are in their own packages/jars and contain following logging-code:
            // Redirect error output
            try {
                myHandler = new FileHandler("myLogging.xml",1000000,2);
            } catch (IOException e) {
              System.out.println("Could not create file. Using the console handler");
            myLogger.addHandler(myHandler);
            myLogger.info("Our first logging message");
            myLogger.severe("Something terrible happened");
            ...When i launch the menuapplication, it writes info to "myLogging.xml.0"
    but when i launch an application, the app writes info to "myLogging.xml.0.1"
    I already tried to leave out the creation of a new Filehandler (try/catch block in code above) but it doesn't help.
    Is it possible to write loginfo to same specific file?

    You should open/close it somehow at every write from different processes.
    But I personally prefer different file names to your forced merging, though.

  • Java.util.concurrent.ConcurrentHashMap

    All,
    I prefer to use the java.util.ConcurrentHashMap over a Hashtable but there are some points regarding this structure that are not very clear to me.
    From java.util.concurrent: Class ConcurrentHashMap:
    "A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updates. This class obeys the same functional specification as Hashtable, and includes versions of methods corresponding to each method of Hashtable.
    *+However, even though all operations are thread-safe, retrieval operations do not entail locking, and there is not any support for locking the entire table in a way that prevents all access. This class is fully interoperable with Hashtable in programs that rely on its thread safety but not on its synchronization details. Iterators are designed to be used by only one thread at a time."+ *
    Also from: Java API: Package java.util.concurrent, we read:
    "The "Concurrent" prefix used with some classes in this package is a shorthand indicating several differences from similar "synchronized" classes. For example java.util.Hashtable and Collections.synchronizedMap(new HashMap()) are synchronized. But ConcurrentHashMap is "concurrent". A concurrent collection is thread-safe, but not governed by a single exclusion lock. In the particular case of ConcurrentHashMap, it safely permits any number of concurrent reads as well as a tunable number of concurrent writes. "Synchronized" classes can be useful when you need to prevent all access to a collection via a single lock, at the expense of poorer scalability. In other cases in which multiple threads are expected to access a common collection, "concurrent" versions are normally preferable. And unsynchronized collections are preferable when either collections are unshared, or are accessible only when holding other locks."
    Based on above, is this correct of I say:
    When using a structure like Hashtable, all the methods or operations are synchronized,
    meaning if one thread is accessing the Hashtable (by get(), put(),... or other methods on this structure), it owns the lock and all other threads will lock out until the thread that owns the lock releases the lock; which means only one thread can access the hash table at a time; which can cause performance issues.
    We need to use a synchronized block or method only of two threads modify a "shared resource", if they do not modify a shared resource, we do not need to use the synchronization.
    On the other hand, the methods of ConcurrentHashMap are not synchronized; so multiple threads can access the ConcurrentHashMap at the same time. But isn't the ConcurrentHashMap itself the "shared resource" that threads are accessing? Should we use it only if the threads are reading from map and not writing to it? And then if threads also write to the structure, then it looks like its better to not to use the ConcurrentHashMap, rather use the regular HashMap with the synchronized wrapper?
    Any help is greatly appreciated.

    We need to use a synchronized block or method only of two threads modify a "shared resource", if they do not modify a shared resource, we do not need to use the synchronization. Actually, you need to synchronize access to the shared resource for both readers and writers. If one thread is updating an unsynchronized HashMap, and a concurrent thread tries to read that map, it may be in an inconsistent state. When synchronizing on the map, the reader will be blocked until the writer completes.
    What you don't need to do is prevent multiple readers from accessing the map, if there's no writer. However, a synchronized map or HashTable will single-thread reads as well as writes.
    On the other hand, the methods of ConcurrentHashMap are not synchronized; so multiple threads can access the ConcurrentHashMap at the same time. But isn't the ConcurrentHashMap itself the "shared resource" that threads are accessing? No, it's actually synchronized at a finer level. Without getting into the details of HashMap implementation, an object's hashcode is used to identify a linked list of hashmap entries. The only time that you have a concurrency issue is when a reader and writer are accessing the same list. So the ConcurrentHashMap locks only the list that's being updated, and allows readers (and writers!) to access the other bucket lists. Plus, it allows two readers to proceed concurrently.

  • Java.util.PropertyPermission...not granted to ProtectionDomain(Stored Proc)

    I'm trying to develop a java stored procedure on Oracle 10.1.2 that makes use of many other libraries, (Axis, WSIF, custom libs), and I'm stuck on this permissions error. I've loaded all of the libs into the same schema under the same user, (with JAVA_ADMIN), and several other privileges. I loaded the files using the following command, "loadjava -verbose -debug -recursivejars -genmissing -resolve -time -fileout loadJava.log -user {userID}/{pwd}@{SID} someJar.jar". The error occurs when a call to WSIFProperties.getProperty attempts to access the org.apache.wsif.mapper or org.apache.wsif.mappingconvention properties.
    In a normal java2 environment, I'd simply edit the java.policy file to provide permissions to the codebase (file:/C:/spi4j2.5.4_J2ee1.4/coreLib/fsgWsif1.1.jar). Since Oracle doesn't have ProtectionDomains, if I add read permissions for those properties using the following command, "call dbms_java.grant_permission( 'SCHEMANAME', 'SYS:java.util.PropertyPermission', 'org.apache.wsif.mapper', 'read' )", it seems as if all of the other classes in the schema should be able to read the property, right? It appears the logfile dump below is showing the permissions that the classloader recognizes. Where did he get those? If they came from the DBA_JAVA_POLICY view, then why can't it pick up on the fact that I've granted read permission to the property it's trying to read? When I tried loading the classes without using the -recursivejars option, I got all kinds of ClassDefNotFound errors and couldn't even start the program, (I guess because it'd loaded the other jars as resources instead of unpacking the classes, the resolver couldn't look into the jars and locate the classes that it needed). The program works just fine outside of the database, (even without me adding read permissions for the codebase to access the properties in the java.policy file). Any help would be greatly appreciated. Thanks in advance.
    Error shown below:
    [2008-03-20 18:23:18.144] [DEBUG] [Root Thread] [org.apache.wsif.*][org.apache.wsif.logging.Trc] [traceIt] [Trc.java:1308] EVENT WSIFMapperFactory.newMapper Caught and handled throwable: java.security.AccessControlException: the Permission (java.util.PropertyPermission org.apache.wsif.mapper read) has not been granted to ProtectionDomain (file:/C:/spi4j2.5.4_J2ee1.4/coreLib/fsgWsif1.1.jar <no certificates>)
    com.fds.classloader.ParentLastUrlClassLoader@e87f10c1
    <no principals>
    java.security.Permissions@c5dd7492 (
    (java.io.FilePermission \C:\spi4j2.5.4_J2ee1.4\coreLib\fsgWsif1.1.jar read)
    (java.net.SocketPermission localhost:1024- listen,resolve)
    (java.util.PropertyPermission java.version read)
    (java.util.PropertyPermission java.vm.name read)
    (java.util.PropertyPermission java.vm.vendor read)
    (java.util.PropertyPermission os.name read)
    (java.util.PropertyPermission java.vendor.url read)
    (java.util.PropertyPermission java.vm.specification.vendor read)
    (java.util.PropertyPermission java.specification.vendor read)
    (java.util.PropertyPermission os.version read)
    (java.util.PropertyPermission java.specification.name read)
    (java.util.PropertyPermission java.class.version read)
    (java.util.PropertyPermission file.separator read)
    (java.util.PropertyPermission java.vm.version read)
    (java.util.PropertyPermission os.arch read)
    (java.util.PropertyPermission java.vm.specification.name read)
    (java.util.PropertyPermission java.vm.specification.version read)
    (java.util.PropertyPermission java.specification.version read)
    (java.util.PropertyPermission java.vendor read)
    (java.util.PropertyPermission path.separator read)
    (java.util.PropertyPermission line.separator read)
    )

    hi rzander,
    I am in a situation similar to your :
    {color:#ff0000}Caused by: java.security.AccessControlException: the Permission (java.io.FilePermission /home/neogeo/Java_Resources.jrxml read) has not been granted to ProtectionDomain (file:/home/neogeo/lib/jasperreports-3.0.0.jar &lt;no signer certificates&gt;)
    AppClassLoader: file:/home/neogeo/lib/xml-apis.jar file:/home/neogeo/lib/jpa.jar file:/home/neogeo/lib/jdt-compiler-3.1.1.jar file:/home/neogeo/lib/png-encoder-1.5.jar file:/home/neogeo/lib/ant-1.5.1.jar file:/home/neogeo/lib/jaxen-1.1.1.jar file:/home/neogeo/lib/mondrian-2.3.2.8944.jar file:/home/neogeo/lib/commons-javaflow-20060411.jar file:/home/neogeo/lib/batik-bridge.jar file:/home/neogeo/lib/antlr-2.7.5.jar file:/home/neogeo/lib/batik-parser.jar file:/home/neogeo/lib/hibernate3.jar file:/home/neogeo/lib/batik-ext.jar file:/home/neogeo/lib/commons-logging-1.0.2.jar file:/home/neogeo/lib/jasperreports-3.0.0.jar file:/home/neogeo/lib/batik-svggen.jar file:/home/neogeo/lib/batik-xml.jar file:/home/neogeo/lib/xml-apis-ext.jar file:/home/neogeo/lib/batik-dom.jar file:/home/neogeo/lib/jakarta-bcel-20050813.jar file:/home/neogeo/lib/servlet.jar file:/home/neogeo/lib/hsqldb-1.7.1.jar file:/home/neogeo/lib/batik-gvt.jar file:/home/neogeo/lib/batik-svg-dom.jar file:/home/neogeo/lib/jxl-2.6.jar file:/home/neogeo/lib/groovy-all-1.5.5.jar file:/home/neogeo/lib/xercesImpl.jar file:/home/neogeo/lib/batik-awt-util.jar file:/home/neogeo/lib/bsh-2.0b4.jar file:/home/neogeo/lib/commons-digester-1.7.jar file:/home/neogeo/lib/batik-css.jar file:/home/neogeo/lib/commons-logging-api-1.0.2.jar file:/home/neogeo/lib/jfreechart-1.0.0.jar file:/home/neogeo/lib/itext-1.3.1.jar file:/home/neogeo/lib/poi-3.0.1-FINAL-20070705.jar file:/home/neogeo/lib/batik-util.jar file:/home/neogeo/lib/commons-beanutils-1.7.jar file:/home/neogeo/lib/jcommon-1.0.0.jar file:/home/neogeo/lib/saaj-api-1.3.jar file:/home/neogeo/lib/batik-script.jar file:/home/neogeo/lib/xalan.jar file:/home/neogeo/lib/batik-anim.jar file:/home/neogeo/lib/commons-collections-2.1.jar
    &lt;no principals&gt;
    java.security.Permissions@1aebb385 (
    (java.io.FilePermission /home/neogeo/lib/jasperreports-3.0.0.jar read)
    (java.util.PropertyPermission user.language write)
    (java.util.PropertyPermission * read)
    (java.lang.RuntimePermission modifyThreadGroup)
    (java.lang.RuntimePermission createSecurityManager)
    (java.lang.RuntimePermission modifyThread)
    (java.lang.RuntimePermission preferences)
    (java.lang.RuntimePermission exitVM)
    (oracle.aurora.security.JServerPermission LoadClassInPackage.*)
    {color}
    {color:#ff0000}
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java)
    at java.security.AccessController.checkPermission(AccessController.java)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java)
    at oracle.aurora.rdbms.SecurityManagerImpl.checkPermission(SecurityManagerImpl.java)
    at java.lang.SecurityManager.checkRead(SecurityManager.java)
    at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:167)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:152)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:150)
    ... 9 more{color}
    I followed your help creating the file  "ORACLE_HOME/javavm/lib/security / java.policy", but I still get the same exception.
    Please, can you post the contents of your java.policy to understand how  you set the permissions ?
    Edited by: NeOGeO on 11-nov-2008 6.43

  • The import "java.util.scanner" is not vaild

    I am experiment with the java.util.scanner API after compiling the code below I received the following error:
    The import "java.util.Scanner" is not valid, since it does not name a type in a package.
    I declared a string variable should that suffice?
    import java.util.Scanner;
    public class Echo {
    public static void main (String[] args)
    String message;
    Scanner scan = new Scanner (System.in);
    System.out.println ("enter something:");
    message = scan.nextLine();
    System.out.println ("hey you entered: \"" + message + "\"");
    }

    Most IDEs let you select and installed JDK for them to use. Check out that IDE's preferences.
    Otherwise, start here and learn to do it with a simple text editor or programmer's editor, and the command line.
    http://java.sun.com/docs/books/tutorial/getStarted/cupojava/

  • Error when importing java.util.Scanner

    Agh! I'm in an introduction to computer science course, and I am writing a program as an assignment that's due tomorrow.
    I have imported java.util.Scanner before, but I've only run it on the Windows PCs in the lab, whereas I am currently on a Mac. I've updated to the latest version of Java (through the software update), and I'm running Tiger (also fully updated).
    I'm using Dr. Java to write the programs, but I tried using the very same thing in Eclipse and it didn't work. Here's my program:
    import java.util.Random;
    import java.util.Scanner;
    public class Password {
    public static void main(String[] args) {
    //create a Scanner object to read from the keyboard:
    String password;
    Scanner scanner = new Scanner(System.in);
    Random randomizer = new Random();
    System.out.println("Please enter a string containing candidate characters.");
    String input = scanner.next();
    int charLength = length(input);
    System.out.print("Random password: ");
    System.out.print(input.substring(randomizer.nextInt(charLength)));
    System.out.print(input.substring(randomizer.nextInt(charLength)));
    System.out.print(input.substring(randomizer.nextInt(charLength)));
    System.out.println(input.substring(randomizer.nextInt(charLength)));
    And, here's my errors:
    4 errors found:
    File: /Users/brianmoore/Desktop/Password.java [line: 11]
    Error: cannot resolve symbol
    symbol : class Scanner
    location: package util
    File: /Users/brianmoore/Desktop/Password.java [line: 18]
    Error: cannot resolve symbol
    symbol : class Scanner
    location: class Password
    File: /Users/brianmoore/Desktop/Password.java [line: 18]
    Error: cannot resolve symbol
    symbol : class Scanner
    location: class Password
    File: /Users/brianmoore/Desktop/Password.java [line: 22]
    Error: cannot resolve symbol
    symbol : method length (java.lang.String)
    location: class Password
    Any ideas?

    Ok. I figured it out. On the Dr. Java page, this is what helped me:
    Please verify the following:
    - Open "/Applications/Utilities/Java/J2SE 5.0/Java
    Preferences";
    make sure "J2SE 5.0" is at the top of the list under
    "Java
    Application Runtime"
    - Open DrJava; go to Edit->Preferences; make sure
    "Tools.jar
    Location", "JSR-14 Location", and "JSR-14
    Collections Path"
    are all blank
    - Open the Help->About dialog box; make sure the "DrJava
    Version" listed is 20050601-0007 or later (that is, later
    than
    June 1, 2005)
    - Go to the "System Properties" tab in the
    "About" box; make
    sure "java.version" is 1.4.2.
    Let us know what you find out if you're still having
    trouble.
    Thanks for your help!

  • When included  import java.util.* then why include import java.util.Gregori

    Hi,
    In my program I hava inported the java package like
    import java.util.*;
    import java.sql.*;
    import java.text.*;
    then for using some classes like Gregorial calender,Date etc,I have to again import
    import java.util.Date;
    import java.sql.PreparedStatement;
    import java.util.GregorianCalendar;
    As far as I know if I have import the above like
    import java.util.*; then it means I can use any classes in java.util ,but if I am not importing
    import java.util.GregorianCalendar;
    import java.util.Date;
    my program is giving error.Can somebody tell me,where my concept is wrong.
    Thanks

    import java.sql.*;
    import java.util.*;
    //import java.util.Date;  // <-- needed to avoid "the type Date is ambiguous"
    public class PackageEg {
        public static void main(String[] args) {
            Date test = new Date();
    }This code gives an error when I compile it, but if I include the
    java.util.Date import it is good. The reason is that there are two
    possible Date classes - one in java.util and one in java.sql. The
    compiler cannot figure out which one I mean.
    If I include a specific class like java.util.Date, then this one will be used
    in preference to any .* imports. (These are called "imports on demand")
    This explains why you need java.util.Date, but the other two are a
    mystery. As far as I know PreparedStatement and GregorianCalander
    are unique names within the packages you mention. Could you post
    some code that will not compile unless the specific import statements
    are there?

  • Errormessage: "java.util.NoSuchElementException"

    Why can't I compile the following code?
    Im using MAC OSX 10.4.10 with the latest J2SE 5.0 Preferences
    import java.util.Scanner;
         class gumballs {
              public static void main(String args[]) {
                   Scanner myScanner = new Scanner(System.in);
                   int gumballs;
                   int kids;
                   int gumballsPerKid;
                   System.out.print("How many gumballs? How many kids? ");
                   gumballs = myScanner.nextInt();     
                   kids = myScanner.nextInt();
                   gumballsPerKid = gumballs / kids;
                   System.out.print("Each kid gets ");
                   System.out.print(gumballsPerKid);
                   System.out.println(" gumballs.");
    } I get the following error when I try to compile the code
    Exception in thread "main" java.util.NoSuchElementException
         at java.util.Scanner.throwFor(Scanner.java:817)
         at java.util.Scanner.next(Scanner.java:1431)
         at java.util.Scanner.nextInt(Scanner.java:2040)
         at java.util.Scanner.nextInt(Scanner.java:2000)
         at gumballs.main(gumballs.java:14)
    How many gumballs? How many kids?
    Program exited with status 1.Please help me! im just a newbie trying to learn java..
    Thanks

    Im on XP and getting the same error message :(
    It compiles fine but when I run it and I am done inputing it gives me that same error message.
    And yes I am running the latest version of JDK
    Also I am having a strange probleming trying to run my files in the command prompt. I can get it to compile fine javac helloworldapp.java and it creates the class. I know my Universal variables are set correctly but when I try java helloworldapp after I have compiled I get a similar error message. I dont know if this is at all related I just started using Java last night so I am a total newb. I would appreciate if one of you pro's could help me out.
    thank you

  • Java.util.Formatter vs. java.text.MessageFormat

    Hi,
    Which formatter is faster java.text.MessageFormat or java.util.Formatter?
    At the moment I format all my strings with java.text.MessageFormat, however I want to speed-up the formatting of the strings that I log, so I though of using java.util.Formatter instead.
    Is there a benchmark that compares between those formatters?

    hanoch_y wrote:
    Why do you day those 2 doesn't do the same thing? They format messages using parameters the user passes.A 747 and a dump truck both do the same thing: move people and cargo from one place to another. But people have been known to express strong preferences for one or the other, depending on their circumstances. They usually have pretty good reasons for their choices.
    No I didn't used a profiler. It just an hunch.Never trust hunches, especially when it comes to performance questions. You'll end up making a fool of yourself every time.

  • Error while deploying a web service whose return type is java.util.Date

    Hi
    I have written a simple web service which takes in a date input (java.util.Date) and returns the same date back to the client.
    public interface Ping extends Remote
    * A simple method that pings the server to test the webservice.
    * It sends a datetime to the server which returns the datetime.
    * @param pingDateRequest A datetime sent to the server
    * @returns The original datetime
    public Date ping(Date pingDateRequest) throws RemoteException;
    The generation of the Web service related files goes smoothly in JDeveloper 10g. The problem arises when I try to deploy this web service on the Oracle 10g (10.0.3) OC4J standalone. it gives me the following error on the OC4J console :
    E:\Oracle\oc4j1003\j2ee\home\application-deployments\Sachin-TradingEngineWS-WS\
    WebServices\com\sachin\tradeengine\ws\Ping_Tie.java:57: ping(java.util.Date) in com.sachin.tradeengine.ws.Ping cannot be applied to (java.util.Calendar) _result  = ((com.sachin.tradeengine.ws.Ping) getTarget()).ping
    (myPing_Type.getDate_1());
    ^
    1 error
    04/03/23 17:17:35 Notification ==&gt; Application Deployer for Sachin-TradingEngineWS-WS FAILED: java.lang.InstantiationException: Error compiling :E:\Oracle\oc4j1003\j2ee\home\applications\Sachin-TradingEngineWS-WS\WebServices: Syntax error in source [ 2004-03-23T17:17:35.937GMT+05:30 ]
    I read somewhere that the conversion between java to xml datatype and vice versa fails for java.util.Date, so it is better to use java.util.Calendar. When I change the code to return a java.util.Calendar then the JDeveloper prompts me the following failure:
    Method Ping: the following parameter types do not have an XML Schema mapping and/or serializer specified : java.util.Calendar.
    This forces me to return a String data.
    I would appreciate if someone can help me out.
    Thanks
    Sachin Mathias
    Datamatics Ltd.

    Hi
    I got the web service working with some work around. But I am not sure it this approach would be right and good.
    I started altogether afresh. I did the following step :
    1. Created an Interface (Ping.java) for use in web Service as follows :
    public interface Ping extends Remote{
    public java.util.Date ping(java.util.Date pingDateRequest)
    throws RemoteException;
    2. Implemented the above interface in PingImpl.java as follows :
    public class PingImpl implements Ping
    public java.util.Date ping(java.util.Date pingDateRequest) throws RemoteException {
    System.out.println("PingImpl: ping() return datetime = " + pingDateRequest.toString());
    return pingDateRequest;
    3. Compiled the above 2 java files.
    4. Generated a Stateless Java Web Service with the help of JDeveloper. This time the generation was sucessful.(If I had "java.util.Calendar" in place of "java.util.Date" in the java code of the above mentioned files the web service generation would prompt me for error)
    5. After the generation of Web Service, I made modification to the Ping interface and its implementing class. In both the files I replaced "java.util.Date" with "java.util.Calendar". The modified java will look as follows :
    Ping.Java
    =========
    public interface Ping extends Remote{
    public java.util.Calendar ping(java.util.Calendar pingDateRequest)
    throws RemoteException;
    PingImpl.Java
    ================
    public class PingImpl implements Ping
    public java.util.Calendar ping(java.util.Calendar pingDateRequest) throws RemoteException {
    System.out.println("PingImpl: ping() return datetime = " + pingDateRequest.toString());
    return pingDateRequest;
    6. Now I recompile both the java files.
    7. Withour regenerating the Web Service I deploy the Web Service on OC4j 10.0.3 from JDeveloper. This time the deployment was sucessful.(The Deployment fails if I don't follow the step 5.)
    8. Now I generated a Stub from JDeveloper and accessed the stub from a client. It works fine. Here if you see the Stub code it takes java.util.Date as a parameter and returns a java.util.Date. (Mind you I am accepting a java.util.Calendar and returning the same in my Web Service interface. Step 5)
    The confusing thing is the Serialization and Deserialization of Data from Client java data to Soap message and Soap message to Server java data.
    From Client to SOAP :
    java.util.Date to datetime
    From SOAP to Server :
    datetime to java.util.Calendar
    From Server to SOAP :
    java.util.Calendar to datetime
    From SOAP to Client :
    datetime to java.util.Date (I am not able to understand this part of the conversion)
    Any help or inputs would be appreciated.
    Thanks
    Sachin Mathias

Maybe you are looking for

  • Lighting fried my Ethernet port

    A Lightning strike fried my Router and Ethernet Port. I've bought and new asdl router and this works with my laptop. I've done a hardware test on my desktop g4 and everything appears fine. Using both the 'System Profile' and 'Hardware Test' the ether

  • How to make connection Pool for standalone Application

    hi I have got an application to craete a stadalone appliaction for connection pool.But it is taking m more time to create the Connection and fetch the data. import java.sql.*; import java.util.*; /** A class for preallocating, recycling, and managing

  • Hide unchecked songs in Library

    I have substantially more disk space on my laptop than I have on my iPod 30GB. I transferred my entire collection, and now I have a lot of duplicates. I have manually unchecked the songs after using Show Duplicate Songs method. I have synched my iPod

  • Crashing and slow performance in Elements 8.0

    Been using Adobe products for years and I feel lucky that everything up until this point has been relatively bug-free and flawless (for me anyway).  I feel like the main problem is in Windows Vista/7 because I never had issues in XP.  Regardless, her

  • Apple pages will not install on my iPhone 5, what do I do?

    I downloaded apple pages because I really did enjoy keynote greatly, however it got delete by mistake. Now when I go to re-download it I continuously get the message "you've already purchased this, so it will download now at no additional charge"...b