This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes JDK1.4 Could not lock System prefs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "JDK1.4 Could not lock System prefs" Watch "JDK1.4 Could not lock System prefs" New topic
Author

JDK1.4 Could not lock System prefs

David Chan
Ranch Hand

Joined: Jun 11, 2003
Posts: 30
My java program work fine in PC. Then, when I try to move it to Unix platform (JDK version: 1.4.0_02) and test the compatibility, it can work properly but shows following error message:
Jan 14, 2004 11:28:50 PM java.util.prefs.FileSystemPreferences$2 run
WARNING: Could not create system preferences directory. System preferences are unusable.
Jan 14, 2004 11:28:58 AM java.util.prefs.FileSystemPreferences checkLockFile0ErrorCode
WARNING: Could not lock System prefs.Unix error code 2334152.
Jan 14, 2004 11:28:58 AM java.util.prefs.FileSystemPreferences syncWorld
WARNING: Couldn't flush system prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
Jan 14, 2004 11:29:28 AM java.util.prefs.FileSystemPreferences checkLockFile0ErrorCode
WARNING: Could not lock System prefs.Unix error code 2334152.
Jan 14, 2004 11:29:28 AM java.util.prefs.FileSystemPreferences syncWorld
WARNING: Couldn't flush system prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
I have solved the problem by creating the missing directories and files under /etc:
Directory: /etc/.java/.systemPrefs
drwxr-xr-x 2 root other 512 Jan 14 12:26 .
drwxr-xr-x 3 root other 512 Jan 14 12:26 ..
-rw-r--r-- 1 root other 0 Jan 14 12:26 .system.lock
-rw-r--r-- 1 root other 0 Jan 14 12:26 .systemRootModFile
1. Can someone explain what purpose of above 2 files?
2. What APIs are they related to?
3. Should I document this in the installation note?
Thank you

David
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

My question is why your code is trying to access System file properties anyway. I don't remember any requirements in the assignment asking for this feature.
What code is causing these errors? I'd probably remove them from your code.
The assignment is designed so you don't have to access OS files like that, so that you can simply move your application from one OS to another without any issues to deal with.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
David Chan
Ranch Hand

Joined: Jun 11, 2003
Posts: 30
This is a JDK bug!!!
I have tried to remove /etc/.java directory and run the test program.
import javax.swing.JFrame;

public class Test {
public static void main(String[] args) {
new JFrame().show();
}
}
It will appear the error message if run by JDK1.4, but when I change to use JDK1.3, that message does not appear again. Therefore, I am sure that there is no problem in my java code.
Since I use JDK1.4 to develop the program, I think it is better to add some information about this bug in the installation note because maybe not all graders know this bug.
For detail, refer this link:
Disable system preferences
David
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi David,
Perhaps you should upgrade to a later version of the JDK? I am using:

on my Linux machine, and I could not replicate your problem. I also tried leaving your application running for 60 seconds to allow the timer to expire, and adding the code to allow a clean exit (rather than a ctrl-c).
I ensured that I do not have an /etc/.java directory nor do I have a ~/.java directory.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Jay Bromley
Ranch Hand

Joined: Aug 09, 2003
Posts: 48
Hello,
For what it's worth, I use


java version "1.4.2_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_02-b03)
Java HotSpot(TM) Client VM (build 1.4.2_02-b03, mixed mode)

and I can't replicate the problem.
Regards,
jb
David Chan
Ranch Hand

Joined: Jun 11, 2003
Posts: 30
I have downloaded the latest JDK to compile the code, all OK. But I run the application, it failed. Please help.
When I type java -jar runme.jar, show the following error message:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /opt/j2sdk1.4.2_03/jre/lib/sparc/motif12/libmawt.so
: ld.so.1: java: fatal: libXm.so.4: open failed: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1560)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1456)
at java.lang.Runtime.load0(Runtime.java:737)
at java.lang.System.load(System.java:811)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1560)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1477)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)
at java.awt.Component.<clinit>(Component.java:506)
at suncertify.RunMe.main(RunMe.java:22)
I have checked the directory /opt/j2sdk1.4.2_03/jre/lib/sparc/, there only have motif21 directory but have no motif12 directory.
My solarix version:
SunOS labppsms 5.6 Generic_105181-28 sun4u sparc SUNW,Ultra-80
JDK version:
java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)

David
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDK1.4 Could not lock System prefs
 
Similar Threads
Changing run levels in Linux
Need help with Unix Scripts
vb.net client accessing jboss web service... Sounds easy, no?
404 error
is my tomcat there?---UNIX