I try looking online for solution, but couldn't find one. It my first time using codenameone , why does import java.util.Scanner doesn't work with codenameone project in eclipse?
I know the JAVA_HOME path is good and everything is updated.
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
This is a common issue with a freshly installed Java on windows, you can solve this by doing the following:
Go to your Start Menu and type regedit into the search field.
Navigate to path HKEY_LOCAL_MACHINE\Software\JavaSoft (Windows 10 seems to now have this here: HKEY_LOCAL_MACHINE\Software\WOW6432Node\JavaSoft)
Right click on the JavaSoft folder and click on New -> Key
Name the new Key Prefs and everything should work.
Alternatively, create a new file named java.reg with the following content and execute it:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs]
Related
I tried to open the Groovy Shell (groovysh) on Windows 8 and got the following output:
java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs
at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
After printing the above message the shell started as expected.
Dennis answer is correct. However I would like to explain the solution in a bit more detailed way (for Windows User):
Go into your Start Menu and type regedit into the search field.
Navigate to path HKEY_LOCAL_MACHINE\Software\JavaSoft (Windows 10 seems to now have this here: HKEY_LOCAL_MACHINE\Software\WOW6432Node\JavaSoft)
Right click on the JavaSoft folder and click on New -> Key
Name the new Key Prefs and everything should work.
Alternatively, save and execute a *.reg file with the following content:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs]
I was able to resolve the problem by manually creating the following registry key:
HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs
This is actually a JDK bug. It has been reported several times over the years, but only in 8139507 was it finally taken seriously by Oracle.
The problem was in the JDK source code for WindowsPreferences.java. In this class, both nodes userRoot and systemRoot were declared static as in:
/**
* User root node.
*/
static final Preferences userRoot =
new WindowsPreferences(USER_ROOT_NATIVE_HANDLE, WINDOWS_ROOT_PATH);
/**
* System root node.
*/
static final Preferences systemRoot =
new WindowsPreferences(SYSTEM_ROOT_NATIVE_HANDLE, WINDOWS_ROOT_PATH);
This means that the first time the class is referenced both static variables would be initiated and by this the Registry Key for HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs (= system tree) will be attempted to be created if it doesn't already exist.
So even if the user took every precaution in his own code and never touched or referenced the system tree, then the JVM would actually still try to instantiate systemRoot, thus causing the warning. It is an interesting subtle bug.
There's a fix committed to the JDK source in June 2016 and it is part of Java9 onwards. There's also a backport for Java8 which is in u202.
What you see is really a warning from the JDK's internal logger. It is not an exception. I believe that the warning can be safely ignored .... unless the user code is indeed wanting the system preferences, but that is very rarely the case.
Bonus info
The bug did not reveal itself in versions prior to Java 1.7.21, because up until then the JRE installer would create Registry key HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs for you and this would effectively hide the bug. On the other hand you've never really been required to run an installer in order to have a JRE on your machine, or at least this hasn't been Sun/Oracle's intent. As you may be aware Oracle has been distributing the JRE for Windows in .tar.gz format for many years.
If anyone is trying to solve this on a 64-bit version of Windows, you might need to create the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Prefs
The problem is that simple console can't edit the registry. No need to edit the registry by hand, just launch the groovysh once with administrative priveleges. All subsequent launches work without error.
Had a similar problem when starting apache jmeter on windows 8 64 bit:
[]apache-jmeter-2.13\bin>jmeter
java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
Successfully used Dennis Traub solution, with Mkorsch explanations. Or you can create a file with the extension "reg" and write into it the following:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs]
... then execute it.
I was getting the following message:
Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002
and it was gone after creating one of these registry keys, mine is 64 bit so I tried only that.
32 bit Windows
HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs
64 bit Windows
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Prefs
This happened to me.
Apparently it is because Java does not have permission to create registry keys.
See: Java: java.util.Preferences Failing
The problem is indeed the register key that is missing. It can be created manually
OR
it can be created automagically by running the program as administrator once. That will give the program the permissions required, and when it will be ran as normal it will still work correctly.
When trying to start AnyLogic, it throws the following error:
Failed to create Java Virtual Machine
Try these steps in order:
Try to restart your machine.
If that does not help, go into the AnyLogic installation folder (somewhere like C:/Program Files/AnyLogic 7 Professional/) and open the file AnyLogic.ini with an editor.
Replace the existing line "-Xmx1024M" with "-Xmx256M"
save & close.
I have a simplified program that produces the following output, in which the lines starting with ^ are generated by my code. Note that I deliberately deleted the Prefs key in HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft.
^ A preferences file was found
Aug 09, 2013 2:45:23 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002.
Windows RegCreateKeyEx(...) returned error code 5.
^ doallunconditionally: false
^ footnotespopup: false
^ thumbnailsgenerated: true
^ thumbnailwidth: 200
^ pathin: C:/Users/Das/Google Drive
^ pathout: C:/Users/Das/ottmar/site
^ pathlog: C:/Users/Das/ottmar/logs
My question is, can I bypass the registry entirely? I thought I should be able to.
I can post the source code (180 lines) if needed.
I eventually discovered a workaround (not a solution) to this problem. As I stated before, I had inadvertently/foolishly deleted the Prefs node in Software\JavaSoft in the Registry, and when I recreated it the message went away.
I now assume that the Windows registry is used whether you like it or not.
This page explains how to use a preferences store apart from the Windows registry:
http://www.davidc.net/programming/java/java-preferences-using-file-backing-store
I've not tried it but it seems to be fairly straightforward. You can also checkout:
Is there a way to use java.util.Preferences under Windows without it using the Registry as the backend?
I'm attempting to use the lwjgl library and I'm starting from scratch on a new Windows 7 install.
I downloaded the latest JDK 6 from the Oracle website. After installing it, I found that commands like "java" or "javac" weren't being recognized from a windows cmd prompt. So, I edited my path variable and appended the jdk's bin folder to it.
Now the java commands work.
So, I download the latest lwjgl, extract it and read the installation instructions on their website:
Download the distribution Unpack the
archive, file contents (in sub
folders) should include (amongst other
things):
lwjgl.dll lwjglaudio.dll lwjgl.jar
lwjgl_util.jar lwjgl_test.jar
Test
LWJGL by opening a command prompt, and
navigating to the folder where the
archive was extracted. Once navigated,
issue the following command: (all in
one line, space before each -option)
java -cp .;res;jar\lwjgl.jar;jar\lwjgl_test.jar;jar\lwjgl_util.jar;jar\lwjgl_fmod3.jar;jar\lwjgl_devil.jar;jar\jinput.jar;-Djava.library.path=native\windows org.lwjgl.test.WindowCreationTest
A window should appear and you should
see the following output:
Found display modes 240, 320,
WindowCreationTest Display created
Moving to 100, 100 Window created 600,
800, Game
So, I extracted it and navigated to the extracted folder in a cmd prompt.
I then executed the test command specified above and I get the following error:
C:\Users\Nestor\Downloads\lwjgl-2.6\lwjgl-2.6>java
-cp .;res;jar\lwjgl.jar;jar\ lwjgl_test.jar;jar\lwjgl_util.jar;jar\lwjgl_fmod3.jar;jar\lwjgl_devil.jar;jar\ji
nput.jar;-Djava.library.path=native\windows
org.lwjgl.test.WindowCreationTest
The
following keys are available: ESCAPE:
Exit test ARROW Keys: Move window
when in non-fullscreen mode L:
List selectable display modes 0-8:
Selection of display modes F:
Toggle fullscreen SHIFT-F:
Toggle fullscreen with
Display.destroy()/create() cycle
Exception in thread "main"
java.lang.UnsatisfiedLinkError: no
lwjgl in java.libr ary.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at org.lwjgl.Sys$1.run(Sys.java:73)
at java.security.AccessController.doPrivileged(Native
Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:82)
at org.lwjgl.Sys.(Sys.java:99)
at org.lwjgl.opengl.Display.(Display.java:130)
at org.lwjgl.test.WindowCreationTest.initialize(WindowCreationTest.java:
82)
at org.lwjgl.test.WindowCreationTest.main(WindowCreationTest.java:286)
C:\Users\Nestor\Downloads\lwjgl-2.6\lwjgl-2.6>
Why am I getting that error? I don't understand why there should be linking errors. In the command that I attempted to execute it clearly spells out the path to those native dll's it needs:
C:\Users\Nestor\Downloads\lwjgl-2.6\lwjgl-2.6>java
-cp .;res;jar\lwjgl.jar;jar\ lwjgl_test.jar;jar\lwjgl_util.jar;jar\lwjgl_fmod3.jar;jar\lwjgl_devil.jar;jar\ji
nput.jar;-Djava.library.path=native\windows
org.lwjgl.test.WindowCreationTest
I've confirmed that the relative path "native\windows" contains those dependencies:
C:\Users\Nestor\Downloads\lwjgl-2.6\lwjgl-2.6\native\windows>dir
Volume in drive C has no label.
Volume Serial Number is 2061-75F6
Directory of C:\Users\Nestor\Downloads\lwjgl-2.6\lwjgl-2.6\native\windows
11/24/2010 12:35 AM .
11/24/2010 12:35 AM ..
10/18/2010 08:44 PM 31,232 jinput-dx8.dll
10/18/2010 08:44 PM 65,024 jinput-dx8_64.dll
10/18/2010 08:44 PM 29,696 jinput-raw.dll
10/18/2010 08:44 PM 62,464 jinput-raw_64.dll
10/18/2010 08:44 PM 197,120 lwjgl.dll
10/18/2010 08:44 PM 305,664 lwjgl64.dll
10/18/2010 08:44 PM 56,832 OpenAL32.dll
10/18/2010 08:44 PM 157,184 OpenAL64.dll
8 File(s) 905,216 bytes
2 Dir(s) 155,163,058,176 bytes free
Can anyone help point out what I'm doing wrong? Can anyone reproduce this by downloading the LWJGL library and attempting to run the test command given in the installation instructions?
It seems that you do not have a space between your classpath argument (-cp jar1.jar;jar2.jar) and your system property setting (-D..).
E.g. your classpath looks like this-cp .;res;jar\lwjgl.jar;jar\lwjgl_test.jar;jar\lwr...;-Djava.library.path=native\windows. This way java will interpret your property setting of native library path argument like a classpath!
Just add a space between those arguments and you should be up and running, this is the corrected command (also tested on Windows 7):
java -cp jar\lwjgl.jar;jar\lwjgl_test.jar;jar\lwjgl_util.jar -Djava.library.path=native\windows org.lwjgl.test.WindowCreationTest
Note that I removed the unused jars from the classpath since you only want to run the WindowCreationTest example.
Check again that directory
C:\Users\Nestor\Downloads\lwjgl-2.6\lwjgl-2.6\native\windows
exists and contains lwjgl.dll and lwjglaudio.dll
I believe that something is wrong with your installation, i.e. the directory does not exist or files are not there.
Just throwing this out there, because Ive had some issues related to this. Go to your Java/JRE/BIN folder. Right click on Java, and go to properties. Under Privilege Level, check the box by run as an administrator.
in one of my questions ,somebody said that I have to make sure that I'm not using compiler 1.6 and 1.5 runtime when i want to execute or debug my program,but I don't know how can i check compiler and runtime in NetBeans ,I am beginner with NetBeans.
my question was:
**I debug my project and the result was :
debug: Have no FileObject for C:\Program Files\Java\jdk1.6.0_02\jre\lib\sunrsasign.jar
Have no FileObject for C:\Program Files\Java\jdk1.6.0_02\jre\classes**
what should i do?
and he answers : you have to make sure that you are not using compiler 1.6 and 1.5 runtime when you want to execute or debug your program
Here's what I use to find out everything about my building environment (never felt too warm with Eclipse):
import static java.lang.System.out;
public class Zeug {
static String[] opts = new String[] { "java.version", "java.vendor",
"java.vendor.url", "java.home", "java.vm.specification.version",
"java.vm.specification.vendor", "java.vm.specification.name",
"java.vm.version", "java.vm.vendor", "java.vm.name",
"java.specification.version", "java.specification.vendor",
"java.specification.name", "java.class.version", "java.class.path",
"java.library.path", "java.io.tmpdir", "java.compiler",
"java.ext.dirs", "os.name", "os.arch", "os.version",
"file.separator", "path.separator", "line.separator", "user.name",
"user.home", "user.dir" };
public static void main(String[] args) {
for(String o : opts) {
out.println(o + ": " + System.getProperty(o));
}
}
}
Go to Tools-->Java Platform and you should see the JDK you are using listed. I am using java-6-sun-1.6.0.16 which does indeed have the jar file you need.
Download the latest JDK from Sun. Go to Tools-->Java Platform and click Add Platform. Navigate to where you installed the latest JDK, name it something meaningful like JDK 1.6.0.16 or whatever and click Finish. Right click on the top level of your project and click Properties. At the top of the popup window change the Java Platform to the one you just added and click ok. At that point, you should not experience your current problem when you compile.
JDK Download Link
You can set the Java version to be used in the project properties (right click on the project).
Edit: after seeing your specific error message: this seems to be a deeper problem. For some reason Netbeans is looking for a file sunrsasign.jar, which is not normally part of the JDK. Looking for the filename on Google indicates that it's part of a cryptography extension, but that seems to have been integrated into the JDK by now. So the JAR is not needed anymore.
I don't know whether it's Netbeans (are you using the most recent version?) or your application that is mistakenly looking for a JAR that has been integrated into the JDK library itselt.