Timer Class in jsdk 1.4 w2000 doesn't compile

Since this is based in the tutorial, shouldn't be a big deal but I spent the whole day looking for a solution. Please help!
The tutorial presents this program:
//1.3
import java.util.timer;
public class Problem {
public static void main(String[] args) {
final Timer timer = new Timer();
timer.schedule(new TimerTask(), 5000);
System.out.println("In 5 seconds this application will exit. ");
     public class TimerTask implements Timer {
public void run() {
System.out.println("Exiting.");
timer.cancel();
My problem starts because java.util doesn't have the timer class:
Problem.java:2: Class java.util.timer not found in import.
import java.util.timer;
^
Now, JSDK 1.4 doesn't have timer as a package, but as a class, nevertheless, the instruction:
import java.util.*; // instead of java.util.Timer
doesn't compile because
Problem.java:10: Interface Timer of inner class Problem. TimerTask not found.
Problem.java:6: Class Timer not found in type declaration.
I think Timer should be expressed as abstract, but how?
I'm new in Java and feel a little frustrated...

>
ProblemSolved.java:3: Class java.util.Timer not found
in import.
import java.util.Timer;
^
1 error
Then you are not using java 1.3. You are using something before that.
for the Timer and
javac IteratorDemo.javaIteratorDemo.java:1: Interface java.util.Iterator of
class IteratorDemo not foun
d.
public class IteratorDemo implements
java.util.Iterator {
^
1 error
And this suggests that you are using something before 1.2.
Just a thought...
Windows comes with the MS version of java, which matches something like 1.1.6. It is in the path. So does you path put the jdk path first or last?

Similar Messages

  • SetDelay() in Timer class

    hi,
    A small doubt ? can we sleep for a while if we are using Timer class .
    I used setDelay(1000) method. but it doesn't work like in Thread.sleep(1000). can anybody suggest me.
    Thanks ,
    -balaji

    Assumption: you refer to javax.swing.Timer
    Timer timer = new Timer();
    timer.start();
    ...//do stuff
    ...//blah, blah, blah
    //need timer to stop for 2 seconds, give or take
    timer.stop();
    try{
        Thread.sleep(2000);
    }catch(InterruptedException ie){
        ie.printStackTrace();
    timer.start();Does that work for you?

  • Combining LVOOP DVR with Asynchronous Dynamic Dispatch and Preserve Run-Time Class

    OK, the title sounds like a cornucopia of LVOOP terms.  But there's a reason.  This is in a way an extension of THIS thread.
    What I'm doing recently is creating a LVOOP approach to loading Completely Asynchronous UI elements into subpanels.  This I have combined with a global repository for the objects (which are essentially singletons with a UI functionality) which are shared via DVR, thus eliminating a lot of synchronisation headaches).
    This means that I can ahve a universal framework for launching the UI elements into a subpanel.  The changes made on the Object there are automatically reflected in the global repository.
    So far so good.
    What I don't like too much is a combination of two seemingly awkward code constructs I need in order to keep things running.
    Weird construct 1:
    I have defined a "Launch UI" function in my parent class which is Dynamic Dispatch (Allowing each object to take care of launching its own UI).  This takes a parent object DVR as a second input which I make sure is of the exact same type as the object type being invoked by using the code shown below.  The ACTUAL Type of both inputs to the launch VI within the IPE are identical.  This is guaranteed because I require each new class to override this function.
    Here I pass the DVR from outside the IPE to the "Launch" VI but the Object obtained within the IPE retains information required for DD thus ensuring that the VI called for launching the UI is identical to the ACTUAL object type in the DVR.  This works OK and by placing this weird construct WITHIN the parent class, abuse is minimised, it works fine and seems to have no major side-effects.
    So now we have a VI running asynchronously in the background which belongs to a specific object but has a DVR which it *thinks* is of a Parent Type but, because of the steps taken earlier, is actually of the same type as the object itself.
    In order to make use of the functionality defined in this actual object type, I need to continuously re-interpret the Object within the IPE as shown below.  Otherwise only the Parent functionality is available.
    If I am accessing only methods of the parent class, then the Preserve functionality is not needed.
    Is there a more elegant way to do this?  I find the net result of this code and type-juggling to be really useful and much easier to manage than the non-DVR route since the synchronisation issues disappear.  By making the IPE usage near-atomic we remove the chances of deadlock.
    All editing done in the UI of the asynchronous VI is reflected automatically in any subsequent usage of the DVR.  Even if the DVRs are not shared between VIs, this makes (for me) the headache of synchronisation easier.  If you start expanding this beyond the limits of a single VI, the benefits in Synchronisation become really huge.  You can even have multiple UI objects operating on the same data in the background without extra synchronisation needs.  The only synchronisation required is a global "Data updated" for the object in question whereby the UI elements simply update their indicators and controls from the DVR again.  This is trivial.
    Thus I am convinced that the net result of this is very beneficial.
    My question is if there's a better, safer or more "official" way to do this?
    I was about to start a new Idea for combining the "Preserve Run time Class" and the DVR Terminal of the IPE so that the casting is done automatically.  We could then have a double input to the IPE, the DVR (of base type) plus the ACTUAL Type of the object but of course returning an error if the types are incompatible.  It would be like an "Imposter" DVR input for the IPE which allows a re-interpretation of the object type.
    Would all of this go away if we allowed Dynamic Dispatch to work with DVRs?  Probably.
    Shane
    Say hello to my little friend.
    RFC 2323 FHE-Compliant
    Solved!
    Go to Solution.

    You guys rock!
    I didn't even think of casting the DVR like that.  Kinds stupid of me but I never would have thought it would work.  Cool.
    Also, Yeah, the limitation of no IPE in the Launch VI was one I spotted quite early on.  this is why my Launch VI also doesn't accept more data than is absolutely neccessara because a DVR access in that VI will of course cause a lockup.  I have the system so far now that I can have a SINGLE Launch VI (Which is NOT overridden, so the limitation refers to only a single VI now which is certainly better.
    So again guys, thanks for helping out an old newbie.  I've been around for quite a while, have made many posts but I love the way I just keep learning from others in the Forum.  This is just why I absolutely LOVE it here. 
    Shane.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

  • Change Timer Class Delay time

    Is it possible to update the Timer Class Delay time while it
    is running. I want to update it using the slider component however
    it doesn't seem to update. I even stop the timer on the THUMB_PRESS
    event of the slider that restart it after it is changed. Doesn't
    seem to work that way either. Any Ideas?

    I figured it out. Instead of setting a variable speed in the
    event handler function for the slider I direclty changed the timer
    delay variable to equal the slider value. I feel dumb now but it
    works great.

  • Forte Timer Class

    From: "GAUR, Anurag" <[email protected]>
    Date: Mon, 17 May 1999 14:03:39 -0400
    Subject: Forte Timer Class
    Hi,
    I'm using Forte's Timer class in developing a Scheduler for our project.
    I have noticed the tick event generated by the Timer class is always late.
    For a timer of 30 minutes duration, the event generated is late by 36
    seconds, for a timer
    of 6 hours duration, its late by 7 minutes and 12 seconds. And for a timer
    of 24 hours
    duration its late by 28 minutes and 49 seconds.
    Any idea why Timer class is behaving like this. Is Timer class notsupposed
    to be
    used for long duration of time ?
    Thanks,
    Anurag GaurAnurag,
    What you have described is consistent with a case I opened last October.
    The case # is 48702- You may want to look it up. Essentially there is a
    defect in the Forte runtime which we observed on Solaris 2.6. Forte on
    Solaris uses the Forte thread package, and the correction for this will go
    very deep. Forte has acknowledged the bug but its probably not going to be
    fixed on version 3. On platforms such as NT native threads are used and
    the problem does not appear. It also doesn't appear on Digital Unix. Our
    workaround is to do time polling in an event loop which works but it's not
    pretty as compared to the Timer.WaitUntil method.
    Good Luck ....
    Charlie Shell
    Information Services, Bell Atlantic Mobile
    2000 Corporate Drive, Orangeburg NY 10962
    E-Mail: [email protected]
    Tel: (914) 365-7927 Cell: (908) 770 -0096
    Pager: 1-800-SKY-8888 pin 6300432
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    What h/w and s/w are you using?
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

  • Want to use Timer class!!!

    I want to make a digital clock using Timer class of swing package to call method repaint() after every 1000 miliseconds which is capable to calling method actionPerformed of Interface ActionListener.
    What changes need to do in my given code for that task?
    import java.util.Calendar;
    import java.awt.*;
    import javax.swing.*;
    public class DClock extends JFrame{
    public DClock()
    super("DIGITAL CLOCK");
    getContentPane().setBackground(Color.WHITE);
    setSize(300,150);
    setVisible(true);
    public void paint(Graphics g)
    super.paint(g);
    Calendar calendar = Calendar.getInstance();
    int hour = calendar.get(Calendar.HOUR_OF_DAY);
    int minute = calendar.get(Calendar.MINUTE);
    int second = calendar.get(Calendar.SECOND);
    g.setFont(new Font("Serif",Font.BOLD,36));
    g.setColor(Color.BLUE);
    g.drawString(hour + ":" + minute / 10 + minute % 10 +
    ":" + second / 10 + second % 10, 85, 60);
    repaint();
    public static void main(String[] args) {
    DClock application=new DClock();
    application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    dont know is any body see this but he is using
    recursion. (i think) repaint tell the ui that is must
    call the pain method. It's easy to find out if you're unsure. Just have a look.
        public void repaint() {
         repaint(0, 0, 0, width, height);
    public void repaint(long tm, int x, int y, int width, int height) {
         if (this.peer instanceof LightweightPeer) {
             // Needs to be translated to parent coordinates since
             // a parent native container provides the actual repaint
             // services.  Additionally, the request is restricted to
             // the bounds of the component.
           if (parent != null) {
             int px = this.x + ((x < 0) ? 0 : x);
             int py = this.y + ((y < 0) ? 0 : y);
             int pwidth = (width > this.width) ? this.width : width;
             int pheight = (height > this.height) ? this.height : height;
             parent.repaint(tm, px, py, pwidth, pheight);
         } else {
             if (isVisible() && (this.peer != null) &&
              (width > 0) && (height > 0)) {
              PaintEvent e = new PaintEvent(this, PaintEvent.UPDATE,
                          new Rectangle(x, y, width, height));
              Toolkit.getEventQueue().postEvent(e);          
        }So no, it seems like it doesn't. It rather seems to call update.

  • HT1338 Facebook doesn't open in safari on my MacBook Pro, why? Sometimes it opens and aftersome time just hang on and after that doesn't open at all.

    Facebook doesn't open in safari on my MacBook Pro, why? Sometimes it opens and aftersome time just hang on and after that doesn't open at all.

    There seems to be a few bugs with iCloud Mail at times, so send Apple feedback. They won't answer, but at least will know there is a problem. If enough people send feedback, it may get the problem solved sooner.
    Feedback
    Apple support article, but I don't think it really addresses your problem.
    iCloud - Mail Troubleshooting

  • Formatting incoming string with date/time classes?

    Hello,
    In the software I am writing currently I am @ a certain point talking to an external device. sending requests, receiving responses.
    One of the things I find in the response is "20090429094222", as a string.
    I cannot change anything to that, thats the way I get it from the device, so thats where I'll have to start with.
    As you could probably guess this is a date and a time. Now my question. Is there a good way to format this from 20090429094222
    to
    2009-04-29 09:42:22
    using date and or time classes, not using String operations?
    Thanks in advance.

    I found a class containing 2 functions who do exactly what I need, for those intrested:
    public static Date convertStringToDate(String txtFormat, String txtDate) {
            DateFormat dateFormat = new SimpleDateFormat(txtFormat);
            Date date =  dateFormat.parse(txtDate);
            return date;
    public static String formatDate(Date date, String txtFormat) {
            DateFormat dateFormat = new SimpleDateFormat(txtFormat);
            String txtDate = dateFormat.format(date);
            return txtDate;
        }Using them this way gives me exactly what I want:
    Date dt = DateUtil.convertStringToDate("yyyyMMddHHmmss", incomingDateSTring);
    String newDateString = DateUtil.formatDate(dt, "yyyy-MM-dd HH:mm:ss");Problem solved, thanks alot to those who gave me some explanation on the problem.

  • Using server time in  Timer Class

    Hai,
    I have develped an application(stand alone) using swings. the exe runs in all the systems in my company.
    requirement is
    --> application has to be closed at 11.59 P.M everyday.
    i did this task using Timer class. Timer class takes the system time in which the application runs. what i need is the server time. so when the application runs it has to check the server time and when the server time is equal to 11.59 PM application has to be closed.
    so how do i map the timer class to my server time?
    iam breaking my head for this for past few days. is there any way to do this?
    thanks

    1)Do you have one database in total? I mean all Java Application read and save data to this database. If so, try to get time from database by using database function. I recommend you to do this because database is central and all application share data with the database.
    2) You can still call web server in Java application. My link in last post will tell you.
    3) You can write a Java Server application for providing current server time for all your Java application. Socket technique may be used.
    Therefore, solution 1 and solution 2 look simpler than solution 3.

  • Timer class and javax.......

    Hi,
    Downloaded the latest java version to d:\download folder. The downloaded file has the name
    " j2re-1.4.2_03-wndows-i586-p.exe ". The file size was about 14.53MB. Double clicking the same installed j2re1.4.2_03 in "C:\Program Files\java\j2re1.4.2_03" folder.
    When I tried to compile Reminder.java program that comes with online Tutorial
    from within C:\Program Files\java\j2re1.4.2_03 at MS-DOS prompt, I got the error message �class java.util.Timer not found in import�.
    I also have Jdk1.1.3 in C:\jdk1.1.3 folder. When I tried to compile Reminder.java from within C:\jdk1.1.3 at MS-DOS prompt, got the same error message,
    Even after changing path variable to C:\jdk1.1.3\bin. Please help.
    Trying to compile any swing program at both DOS prompts gives error message �javax.__________ not found in import�. Can�t figure out why. Please help.
    ammukalai.

    j2re1.4 is a runtime only (ie j2re = Java Runtime Engine) It will not compile java files.
    The timer class was introduced with Java version 1.3.
    You currently have a very old version of 1.1.3.
    You need to download the j2se1.4.2 SDK - http://java.sun.com/j2se/1.4.2/download.html
    The size is closer to 50MB :-)
    Cheers,
    evnafets

  • Drobo   Time Machine   Thunderbolt to FW adapter = Drobo doesn't get detected

    Hello,
    I have a Drobo (early generation with Firewire) attached to my iMac via Thunderbolt to FW adapter. It's the drive that I use for Time Machine.
    Unfortunately, every time I turn on my iMac, it doesn't detect the Drobo, though if I then unplug and then plug in the Drobo, it will detect it. Obviously, I don't want to have to do this every time I turn on my iMac.
    Any thoughts as to what the issue might be?
    Thanks,
    John

    Hello John C Lin,
    It sounds like you have a firewire device is not detected automatically when you log in, but if you disconnect and reconnect the device it will then be detected. I suggest trying these troubleshooting steps from the article named:
    USB and FireWire Quick Assist
    http://support.apple.com/kb/HT1151?viewlocale=en_US
    Try a different port and cable
    Connect your device to a different USB or FireWire port on your Mac. If you connected your device to a USB or FireWire hub or to a port on another USB or FireWire device that's connected to your Mac (known as daisy chaining), connect your device directly to a port on your computer. Some devices need to draw power from a USB or FireWire port to work; if you connect a device to a non-powered hub (one that isn't plugged in to a power source) or to a low-power port (such as the one on your USB keyboard), it may not work. If you have another known-good cable, try swapping the cable to see if that works. If it does, you should replace the problematic cable.
    Check for device conflicts
    Disconnect all USB or FireWire devices (including hubs and extension cables) except for your Apple keyboard and mouse. Then, connect the device in question directly to your computer. If your device works now, there may be a conflict between that device and one of your other USB or FireWire devices. If it doesn't work, go to tip 8. If you do have a conflict, you can determine which devices are affected. Connect your other devices to your Mac, one by one, making sure to test that each device works before making another connection. When you find the device that causes the issue, contact the manufacturer for assistance (check both manufacturers' websites for software updates and additional information).
    Quit associated applications
    If you're using a particular application that uses the device in question (for example, you're using Image Capture with a USB scanner), try quitting the application and then opening it again.
    Try another user account or computer
    If you have another Mac available, try connecting your device to that other computer to see if it works. If you don't have another computer available, log in to another user account on your Mac (or create a new user account and log in to it), and test the device again. If the device is working now, there may be a software conflict between the device and something in your original user account.
    Check System Profiler for hardware Issues
    Open System Profiler (from the Apple menu, choose About This Mac, then click More Info) and then click either USB or FireWire. If you don't see your device listed in the pane, the issue could be with the device itself or your computer's USB or FireWire port. To rule out the port, plug the device into another USB or FireWire port on your Mac and then check System Profiler again (press Command-R to refresh the window). Also try resetting the FireWire bus. If you see your device listed in the pane but it doesn't work, you may want to contact the device's manufacturer for assistance.
    If the issue is not resolved I would next reset the SMC and the PRAM, then retest the issue:
    Intel-based Macs: Resetting the System Management Controller (SMC)
    http://support.apple.com/kb/ht3964
    And
    About NVRAM and PRAM
    http://support.apple.com/kb/HT1379
    Thank you for using Apple Support Communities.
    All the very best,
    Sterling

  • Need to implement the timer class for 1.1

    Hi
    I am using JDK1.1 for integration with a STB.
    The timer class is not existing for 1.1.
    Where I can find an implementation code of the timer class in order
    to perform a schedule task which work with JDK 1.1
    Thanks
    Fred

    Before you look for Sun's implementation of Timer in post-1.1 versions, make sure you read the licence agreement for those versions and the copyright notice on the code. There's a good chance that by using that code you will be violating one or both of those. This may be a serious issue.
    Your other alternative is to read the API documentation for Timer (and TimerTask) and to write your own implementation. That shouldn't be too difficult.
    I doubt that you will find people actively writing open-source extensions for Java 1.1 since Java 2 has been out for nine years now. Most likely you are on your own there.

  • How to use server time in  Timer Class

    Hai,
    I have develped an application(stand alone) using swings. the exe runs in all the systems in my company.
    requirement is
    --> application has to be closed at 11.59 P.M everyday.
    i did this task using Timer class. Timer class takes the system time in which the application runs. what i need is the server time. so when the application runs it has to check the server time and when the server time is equal to 11.59 PM application has to be closed.
    so how do i map the timer class to my server time?
    iam breaking my head for this for past few days. is there any way to do this?
    thanks

    1)Do you have one database in total? I mean all Java Application read and save data to this database. If so, try to get time from database by using database function. I recommend you to do this because database is central and all application share data with the database.
    2) You can still call web server in Java application. My link in last post will tell you.
    3) You can write a Java Server application for providing current server time for all your Java application. Socket technique may be used.
    Therefore, solution 1 and solution 2 look simpler than solution 3.

  • Timer Class

    Hi
    I am using a timer delay between 2 functions, with the delay of 140ms.  One function triggers an RAW audio file thats embed into the .swf by extending the sound class.
    The problem is, that I am having slight timing issued that seem to be on a global scale.  So far I have to audio channels playing samples that are uncompressed and very short.  I have dicovered and read some adobe cookbooks on the accurateTimer() class, thats been custom built to override the Timer class functions, but I cant seem to get it to work on my set up.
    The app is a music sequencing app that will eventually have 16 channels of audio apposed to the current 2 at present.
    The cookbook is can be found here:
    http://cookbooks.adobe.com/post_Accurate_timer-17332.html
    And my code that drives the audio channels is here:
    var tempo:Number = 125.125;
    var timer:Timer = new Timer(tempo,1);
    timer.addEventListener(TimerEvent.TIMER, switchToColorZero);
    var boxi:int = -1;
    var boxi2:int = -1;
    function changeColours():void
        //trace("changeColours() :" + getTimer());
        ct.color = colour[2];
             if(boxi < boxes.length - 1)
                boxi += 1;
             else
                boxi = 0;
             //if white turn green
             if(boxes[boxi].ONOFF)
                boxes[boxi].transform.colorTransform = ct;
             else
                mix1Transform = new SoundTransform(currVol,currPan);
                mix1 = kick.play();
                mix1.soundTransform = mix1Transform;
                trace(currVol,currPan);
             if(boxi2 < boxes2.length - 1)
                boxi2 += 1;
             else
                boxi2 = 0;
             if(boxes2[boxi2].ONOFF)
                boxes2[boxi2].transform.colorTransform = ct;
             else
                mix2Transform = new SoundTransform(currVol2,currPan2);
                mix2 = hat.play();
                mix2.soundTransform = mix2Transform;
                trace(currVol2,currPan2);
             timer.start();
    function switchToColorZero(e:TimerEvent):void
        //trace("switchToColorZero() :" + getTimer());
            ct.color = colour[0];
            if(boxes[boxi].ONOFF)
                boxes[boxi].transform.colorTransform = ct;
            if(boxes2[boxi2].ONOFF)
                boxes2[boxi2].transform.colorTransform = ct;
            timer.stop();
            timer.reset();
            changeColours();

    What kind of Timer are you writing about..... specify ....
    I know java.util.Timer()
    example with repeats
    java.util.Timer t = new java.util.Timer();
              t.schedule(new java.util.TimerTask() {
                   public void run() {// do something
              }, delay, period);delay - delay in milliseconds before task is to be executed.
    period - time in milliseconds between successive task executions.
    example without repeats
    java.util.Timer t = new java.util.Timer();
              t.schedule(new java.util.TimerTask() {
                   public void run() {// do something
              }, delay);Good Luck

  • Plz help in Timer class

    Plz i want the timer class to start but if a packet was recieved from a client before the time is finished the timer is canceled.
    //e.g
    Datagrampacket rec=new Datagrampacket (byte[],length);
    Timer t=new Timer ();
    t.schedule(MyTimerTask,1000);
    socket.recieve(rec);
    // the timer started and the recieving will not start until the timer stopped.
    //how to make the recieving happen if the timer is still runnig.
    I would be very thankful.

    Starting a timer is asynchroneous, so it will not block. The socket will be able to receive data while the timer is running.
    /Kaj

Maybe you are looking for