Cannot import java.util.concurrent.locks ... WHY?

Why is Xcode unable to find the java.util.concurrent.locks package. The class browser knows it exists. For example the entry for the ReentrantLock class looks like this in the browser class window:

ReentrantLock (java.util.concurrent.locks)

Xcode knows about other java.util packages such as java.util.ResourceBundle which I have been accessed successfully in other parts of my projecgt.

Here is a source file and the resulting compiler error:

--------------------------------
The source file:
// Foo.java
import java.util.ResourceBundle;
import java.util.concurrent.locks;
public class Foo { }

--------------------------------
The compiler error:

compile:
Compiling 2 source files to /Users/Terry/Desktop/JAVA/PROJECTS/Logic/bin
/Users/Terry/Desktop/JAVA/PROJECTS/Logic/src/Foo.java:3: cannot find symbol
symbol : class locks
location: package java.util.concurrent
import java.util.concurrent.locks;
^
1 error

BUILD FAILED

--------------------------------
Help or hints would be greatly appreciated!

Mac Book 2 GHz Intel Core Duo, Mac OS X (10.4.11), Xcode 2.5; Xcode IDE: 799.0; Xcode Core: 798.0; ToolSupport: 794.0

Posted on Jan 21, 2008 2:19 PM

Reply
3 replies

Jan 21, 2008 3:25 PM in response to Terry Beyer

Well the reason to your problem is very simple... java.util.concurrent.locks is a package... Not a class.
if you want to import a specific class, the class should be written at the end like you did for
import java.util.ResourceBundle;
but if you want to import a whole package you need to add the little star at the end :
import java.util.concurrent.locks.*;

Or else, you only import the class you need :
import java.util.concurrent.locks.ReentrantLock;

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Cannot import java.util.concurrent.locks ... WHY?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.