Results 1 to 20 of 20
  1. #1
    Master-N is offline Member
    Join Date
    Feb 2010
    Posts
    10
    Rep Power
    0

    Default Java 3D J3DTimer class and perf

    I recently bought a book on java game programming. One of the first examples uses a class from the Java 3D library. The class is J3DTimer. I wrote the code exactly like the book, which imports J3DTimer. I'm using Eclipse as my IDE and as soon as I write the whole import statement, a red underline under the statement appears to indicate that J3DTimer has restricted access and cannot be imported.

    I've checked around and it seems that J3DTimer is a deprecated class. I installed both Java 3D 1.3.1, which the book suggests to use, and Java 3D 1.5, the newest version. I still get the same error and can't compile the program nor can I access any of J3DTimer's methods.

    Any suggestions in how to get the program to work would be most appreciated.

    I give my thanks in advance for any advice, help, or suggestions.

    EDIT: I forgot to mention that in the example in the book, an extra class is used that imports perf. The book says perf only runs on J2SE 1.4.2 I believe. Is this true?
    Last edited by Master-N; 02-27-2010 at 02:07 AM. Reason: For to mention perf

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  3. #3
    Master-N is offline Member
    Join Date
    Feb 2010
    Posts
    10
    Rep Power
    0

    Default

    J2se jdk 1.5.40_04 jre6

    EDIT: I mean jdk 1.5.0_04
    Last edited by Master-N; 02-27-2010 at 02:40 AM. Reason: wrong version mentioned

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  5. #5
    Master-N is offline Member
    Join Date
    Feb 2010
    Posts
    10
    Rep Power
    0

    Default

    The import statement is as follows:

    import com.sun.j3d.utils.timer.J3DTimer;

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Are sure that the installation is added to class path as well. Because this is not a standard package in JDK so that's why you install the package separately. That's fine, hope you didn't get any error message.

  7. #7
    Master-N is offline Member
    Join Date
    Feb 2010
    Posts
    10
    Rep Power
    0

    Default

    the package came in an executable (exe) file I downloaded from java.sun.com. It placed the jar files in the jdk and jre folders. Do I need to add the class path as well?

    If so, how do I do that?

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Actually if the installation take same JDK folder then it's not necessary. I'm confused with your error message actually, restricted access and cannot be imported, or it says that package is not exist?

  9. #9
    Master-N is offline Member
    Join Date
    Feb 2010
    Posts
    10
    Rep Power
    0

    Default

    The exact message reads:

    Access Restriction:The type J3DTimer is not accessible due to restriction on required library C:\Program Files\Java\jre6\lib\ext\j3dutils.jar

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Please check the permissions on that file. Remove the permission if it's read only. But it cannot be happen. Since you just accessing the file the permission cannot cause any issues. Anyway give a try and let me know. I'll check the package to install later.

  11. #11
    Master-N is offline Member
    Join Date
    Feb 2010
    Posts
    10
    Rep Power
    0

    Default

    hmm... how do I change permissions?

    I right clicked on the jar file in Windows XP, selected properties, and read-only is not selected. Do I have to do something else to check and change permissions?

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    That's what you've to check actually, even it's obvious.

    I tried the package in NetBeans and work fine for me. Is there any documentation, I couldn't found any related to any IDEs actually.

  13. #13
    Master-N is offline Member
    Join Date
    Feb 2010
    Posts
    10
    Rep Power
    0

    Default

    There is documentation but about the package itself. I haven't found any IDE documentation. I'll look into Eclipse documentation. And I'll see other IDEs as well.

    EDIT: I read the documentation for the J3DTimer class and for the Eclipse IDE. J3DTimer is a deprecated class so it seems that Eclipse is flagging the class and restricting access to it. When I run Eclipse, right click the project name, select properties, select Java compiler, select errors/warnings, check Project specific configuration, and scroll down and look at Deprecated API, there is an option for Forbidden Access that gives an error. I can change the option from error to either warning or ignore. If I change that option the red underline under the import and .getResolution() statements turn yellow or disappear. This solves the problem, however, I feel very discouraged to use a class that is deprecated and which the Eclipse IDE documentation and the API documentation do not recommend using. I'll try some other options to get the same effect. Anyway, thanks for the help!
    Last edited by Master-N; 02-27-2010 at 07:04 PM. Reason: Read Documentation

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    If there is any method deprecated there should be an alternative as well. So you can use those. In most of the cases, deprecated methods are not make much damage to the application. However each has advantages and disadvantages, that's why we comes with deprecated stuff time to time.

  15. #15
    nolsen01 is offline Member
    Join Date
    Jul 2009
    Posts
    18
    Rep Power
    0

    Default

    I read that book. I used System.nanoTime() instead.

  16. #16
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by nolsen01 View Post
    I read that book. I used System.nanoTime() instead.
    Relevant what you are talking about?

  17. #17
    nolsen01 is offline Member
    Join Date
    Jul 2009
    Posts
    18
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga
    Quote Originally Posted by nolsen01
    I read that book. I used System.nanoTime() instead.
    Relevant what you are talking about?


    Quote Originally Posted by Master-N View Post
    I recently bought a book on java game programming. One of the first examples uses a class from the Java 3D library. The class is J3DTimer.
    ...
    Any suggestions in how to get the program to work would be most appreciated.

    I give my thanks in advance for any advice, help, or suggestions.
    The book he is referring to is "Killer Game Programming in Java." I also read it. In the book, in Chapter 2, under the section titled "FPS and Sleeping for Varying Times", the very last sentence of the section says:

    "If you're using J2SE 5.0, then replace all the calls to J3DTimer.getValue( ) with System.nanoTime( )."

  18. #18
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  19. #19
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by Master-N View Post
    This solves the problem, however, I feel very discouraged to use a class that is deprecated and which the Eclipse IDE documentation and the API documentation do not recommend using. I'll try some other options to get the same effect. Anyway, thanks for the help!
    hallo master-n

    you're right. i'm reading the same book and must say that the content is not very accurate. the first o' really book that disappoint me.

    nevertheless i will finish reading. a good place to get updates and to complain :) is Killer Game Programming in Java good luck.

  20. #20
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by j2me64 View Post
    nevertheless i will finish reading. a good place to get updates and to complain :) is Killer Game Programming in Java good luck.

    i decide to sell the book Killer Game Programming in Java, because i found an other one. if there are somebody interested in buying this almost new book, send me a pm. thx.

Similar Threads

  1. Replies: 1
    Last Post: 05-31-2009, 11:57 PM
  2. Replies: 1
    Last Post: 05-31-2009, 03:17 PM
  3. Replies: 16
    Last Post: 05-28-2009, 04:41 PM
  4. Replies: 14
    Last Post: 05-28-2009, 06:44 AM
  5. class.java to class.exe
    By f_the_cook in forum New To Java
    Replies: 11
    Last Post: 07-16-2008, 03:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •