Import java.util.Enumeration;

Hi, I test a programmer under eclipe
I can import java.util.Enumeration;(error on Enumeration)
and Vector connections = null;
Enumeration enum = connections.elements();
while (enum.hasMoreElements())
do something
I got error Enumeration can't not be resolve/
why?
and how to modify to change it?

Hi, I test a programmer under eclipe Maybe should test the program, not the programmer ;-)

Similar Messages

  • Import java.util Error

    How come program wont accept import java.util ?
    I get cannot resole symbol ?? i looked in up in my java book and its spelled right . what gives ?

    there is no class named java.util .
    import java.util.ArrayList;
    import java.util.EventObject;
    or
    import java.util.*;

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

    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;

  • USage of import java.util.* & using another package

    When we use import java.util.*; from where does JAVA take the class that are related to util, when I did search for "util" in my machine, I got about 50 results for folders named util and also some where in a folder called "java" when I opened it it did not have the classes, that I was expecting. So I am not clear where does it get the class files from. This is not only for this but for any import commands like import java.io.*;
    When we get another package or source code which was written in java and want to use it in our code where do we have keep the files ? eg. i have the java code that i m writing in c:\java then do I put all the downloaded related files in that folder and then run the code ? or i keep a folder inside java folder and then import them into my code ?
    please do advice.
    Thanks in advance.

    When we use import java.util.*; from where does JAVA
    take the class that are related to util,It means when you use a classname in your code, and that classname is neither in the same package as the class you're writing, nor imported specifically by classname, that it will search for it.
    Where it searches is every folder called util whose parent folder is called java which in turn is at the root level of one of the classpath elements. That is, if classpath contains "A" and "B", and you refer to a class called "Foo", then it will look for "A/java/util/Foo.class" and "B/java/util/Foo.class".
    search for "util" in my machine, I got about 50
    results for folders named util and also some where in
    a folder called "java" when I opened it it did not
    have the classes, that I was expecting. So I am not
    clear where does it get the class files from. This is
    not only for this but for any import commands like
    import java.io.*; All the java.* and javax.* and whatever else it part of the core API is in rt.jar, which lives inside the Java distribution. Classpath elements can be directories or jar files or zip files.

  • Question on import java.util.ArrayList, etc.

    Hi,
    I was wondering what the following meant and what the differences were. When would I have to use these:
    import java.util.ArrayList;
    import java.util.Collections; <--I especially don't understand what this means
    import java.util.Comparator; <---same for this (can I consolidate these into the bottom two?)
    import java.io.*;
    import java.util.*;

    MAresJonson wrote:
    Also, what does this mean:
    return foo == f.getFoo() ? true : false;
    (more specifically...what does the "? true : false" mean and is there another way to code that?)It's called the ternary operator. For your specific example, you could just do:
    return foo == f.getFoo();But, more generally,
      return foo == f.getFoo() ? "equal" : "Not equal";means:
    if (foo == f.getFoo()) {
       return "equal";
    else {
       return "Not equal";
    }As everyone else said at the same time...

  • A problem with importing java.util.concurrent

    I am rather new to Java with not that much experience. I apologize ahead though if this is the inappropriate forum to post this problem and/or this question has been answered somewhere else (I couldn't find a post on this subject).
    Some of my research has lead to using a semaphore if you wish to use the synchronized() method. I looked up that the import for that is under java.util.concurrent.Semaphore; however, thanks to netbeans for pointing this out before I compiled it, this doesn't seem to exist.
    I'm using Java version 1.6.0_03 which does seem to be the latest version. Was it simply removed or am I seriously missing something big here? Anyways, I'm at a total loss and hopefully someone can point me in the right direction.
    Thank you in advance for your help.

    jiju wrote:
    check whether import java.util.concurrent.*; is workingAwesome.
    As for netbeans, I went and double checked to see if it is reading from the most updated folder of Java and it is.
    So as I said, I am totally lost as to why it's not working. Should I just downgrade to a lower version of Java? Although it would seem kinda weird to do something like this.

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

  • Java.util.Enumeration

    Hi all,
    java.util.Enumeration is an interface.
    but we are able to execute the methods (hasMoreElements, nextElement )defined in this interface.
    say for ex:
    java.util.Enumeration en =
    /* (Some code which returns Enumeation say :*/ Hashtable.keys();
    whithout the implementation , we are executng the methods defined in the Enumeration interface. how this is possible?
    thanks in advance.
    dhanasekaran.

    hi,
    I posted the code for the method elements from java.util.Vector which returns an Enumeration. This should explain your problem:public Enumeration elements()
         return new Enumeration() {
             int count = 0;
             public boolean hasMoreElements() {
              return count < elementCount;
             public Object nextElement() {
              synchronized (Vector.this) {
                  if (count < elementCount) {
                   return elementData[count++];
              throw new NoSuchElementException("Vector Enumeration");
    }greetings,
    Stijn

  • Compile error import java.util.map$entry

    Hi,
    I am trying to compile code which imports the following package
    import java.util.Map$Entry.
    The error thrown up is : cant resolve symbol Map$Entry. Why is there a $ in the package import path and is there some configuration required to compile the file.
    I am not allowed to change the code. Does anyone have an idea on how this problem can be solved.
    Thanks and regards
    Kumar Vellal

    Btw java docs for the interface are available at:
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/Map.Entry.html
    Changing the import should probably help compile the code, but without changing the import .. need to check. This is just from what i remember now. Lets see if anyone else comments on this.

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

  • Any benefit to import java.util.Vector over import java.util.*?

    By benefit I mean does it reduce compile time or have some other beneficial side effect to import only those classes you're using in a class rather than importing the package they reside in.
    For example:
    // this?
    import java.util.Vector;
    // or this..
    import java.util.*;
    class Test
         Vector v;
    }Question is strictly academic...I'm just curious.

    I like Dr. clap's answer. Also, though you can
    consider code readability. Obviously importing a
    whole package doesn't give you an idea of what classes
    are being used. "I", personally, have only seen exact
    class imports done when learning something new. This
    is basically just for clarity, and not speed as Dr.
    Clap pointed out.That's probably a good thing to do for examples, but I can't see why you would want to know what individual classes are being used otherwise.
    From a programming standpoint if you're going to build a complex dialog you don't want 500 import statements. If you know you're going to be using lots of classes from an individual package might as well import the whole thing.

  • Import java.util.*?

    Where can I place my imports? I seem to be placing them wrong :)
    <%@ page language="java" import="java.sql.*"%>
    <%!
    // define variables
    String publication;
    String classification;
    String startDate;
    String adText;
    String sqlflag;
    int adCount;
    import="java.util.*";
    import="java.text.*"
    // define database parameters
    String URL = "jdbc:oracle:thin:@server.site.com:1521:ftcs";
    String user = "user";
    String pass = "pass";
    Connection conn;
    %>

    You're doing it right first but getting it wrong later :)
    They need to be in the page directive. Use commas to separate them
    <%@ page language="java" import="java.sql.*, java.util.*, com.whatever.util.*" %>

  • Where to find .jar files so I can implement import java.util.logging

    I'm trying to figure out how to take an application built for Websphere and port it to WebLogic. I've come across this blog entry http://blogs.sun.com/fkieviet/entry/using_java.util.logging_in_bea_weblogic and would like to try creating and using the startup class.
    I have not been able to find the correct jar files.
    import weblogic.common.T3ServicesDef;
    import weblogic.common.T3StartupDef;
    import weblogic.logging.LoggingHelper;
    In reading the documentation on using the NonCatalogLogger APIs at http://download.oracle.com/docs/cd/E12840_01/wls/docs103/i18n/writing.html I also see some code calling for the following imports
    import weblogic.jndi.Environment;
    import weblogic.logging.NonCatalogLogger;
    1. Does anyone know where I can grab these?
    2. There must be a strategy for finding these .jars that people use. If so, what is it?

    I thought I understood you, but the more I look at what you've set here, I'll just be honest and admit that the I don't know what you are saying here:
    'You should be able to add the "weblogic.jar" in the WebLogic distribution to your classpath.' - What doe this mean?
    1. Go to my xxxWeb app Dynamic Web Project and right-click and select Build Path / Configure Build Bath / Libraries - Select Add external JARS and navigate to the weblogic.jar
    2. Go to my xxxWeb app Dynamic Web Project and right-click and select Build Path / Configure Build Bath / Libraries - Select Add Library and try to go from there?
    3. Go to my xxxWeb app Dynamic Web Project and right-click and select Build Path / Configure Build Bath / Libraries - Select Add Variable and try to go from there?
    4. Go to my xxxWeb app Dynamic Web Project and right-click and select Build Path / Configure Build Bath and do something else?
    5. Something else?
    Also, I don't know what you mean here:
    'You don't need to (and you shouldn't) copy that jar file, just have it in your compilation classpath. It will be present automatically at runtime.'
    Sorry for being so simple here but I've been trouble shooting why I can't follow what look like pretty simple steps to implement over-riding the ApplicationLifecycleListener Class to use existing java.util.logging.Logger code by adding the following to the the weblogic-application.xml:
    <wls:listener>
         <wls:listener-class>com.qualcomm.weblogic.log.listener.UtilLogWrapper</wls:listener-class>
    </wls:listener>
    And including as a referenced jar file, a simple POJO class instance of com.qualcomm.weblogic.log.listener.UtilLogWrapper.
    My resrouces for this are:
    1. http://blogs.sun.com/fkieviet/entry/using_java.util.logging_in_bea_weblogic.
    2. http://www.oracle.com/technology/pub/articles/drolet-ant.html.
    Maybe my weblogic.jar is at the root of the problem.
    I hope you can 'dumb this down' for me with a simple explanation of steps to do what you outlined above.

  • Import java.util.Formatter - cannot resolve symbol

    I use j2sdk1.4.2_04
    when I try to compile my program using Formatter, it response error "cannot resolve symbol"
    Pls help!

    Where did you get this java.util.Formatter from? If you check the official 1.4.2 API for Java, that class does not exisit! However, java.util.logging.Formatter, does exisit...
    http://java.sun.com/j2se/1.4.2/docs/api/
    If you ment: java.util.logging.Formatter have you checked the API to make sure you are using it correctly???
    HTH.

Maybe you are looking for

  • DLNA devices adding up in Windows 8 - How do I to avoid / remove them

    My Win8 Pro x64 is connected my home Network. On this network I have 6 IPCams from DLINK. Every time I reboot my Windows 8 (this goes for all my Win 8 / 7 computers) all 6 IPCams is added to the list of MultiMedia Devices. Same name, same IP etc. I c

  • RMAN recovery from tape and disk?

    Hey Guys, Here is my scenario: - I have Oracle 10g and I am using RMAN to backup to disk and then I use Networker to backup on tapes from disk (retention is set to 30 days on tapes). On RMAN - my retention policy is set to recovery window of 5 days a

  • API for Shared Review in Acrobat SDK

    Hi, I would like to implement the functionality for Shared Review programmatically. Right now we need to open each pdf file select Comments -> Send for Shared Review in Acrobat Professional and follow the steps in wizard. I am looking at achieving th

  • Photoshop CS4 web gallery template in Lightroom?

    Hi, I have a custom web gallery template set up in Photoshop CS4. I would like to use it in Lightroom, but it appears the Lightroom web gallery templates are in a different format (and not so customisable). Is there a way I can use my CS template in

  • Removing "Run Only" attribute on AppleScript?

    So, let's say I wrote a killer script. Now I want to use it as the base for another script, but i inadvertently saved my script as "run only". Is there a way to change the attribute of this file (Sort of like a dos attrib command on a pc?)