Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures


Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips


Submit News
Search the site here...
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

Java Newsletters Archive: 171

JavaFAQ Home » Java Newsletters Go to all tips in Java Newsletters

Bookmark and Share

=== [ The Java FAQ Daily Tips, weekly publication ] ===

Issue No: 171 8 July 2003
13563 subscribers

Foreword: Excuse me for possible mistakes. English is not native language for me.

In this issue:
  • 1. When I use InetAddress.getByName if a lookup to the name service failed then ...
  • 2. In Ukraine first day of week is Monday but not Sunday
  • 3. Performance testing has shown that the finalize methods in the channel classes...
  • 4. Latest posts on our message board
  • 5. Link to Java FAQ

  • Hello dear friends!

    Tip 1

    Question: When I use InetAddress.getByName if a lookup to the name service failed then all subsequent lookups of that hostname fail as well for the lifetime of the virtual machine...
    It looks like negative lookups are cashed. What is solution? Is it more bugs I should be aware of?

    Answer: Use latest J2SE 1.4! Prior to J2SE 1.4 negative lookups were always cached. This has changed in 1.4 so that by default if a lookup fails it's possible for a subsequent lookup to succeed. This is particularly important in dial-up environments or environments where the name service is not reliable.

    Also prior to J2SE 1.4.1 the java.net.InetAddress.getLocalHost() would cache the lookup of the IP address of the local machine for the entire session of the application. This behavior poses a problem for applications running on machines that are connected to the internet via a dial-up connection or machines that acquired their addresses through DHCP. This has been corrected in 1.4.1 so that the local IP address is no longer cached. InetAddress.getLocalHost() will return the correct IP address for dial-up connections as well as for DHCP

    Prior to J2SE 1.4 the InetAddress.toString() would perform a lookup via the name service if the hostname wasn't previously resolved. This is no longer the case in 1.4 and toString will return immediately. If the hostname is not resolved the returned string will contain the dotted IP address only.
    Applications that depend on toString() returning a string with the resolved hostname should be aware of this correction in 1.4

    Java wimps please close your ears ... For the Java programmer who
    thought he knew everything there was to know about Java, have a
    look at the most advanced Java newsletter archived on the website
    http://www.smotricz.com/kabutz Guess what, it won't even cost you
    anything! Subscribe today - you won't be disappointed.

    Tip 2

    Question: In Ukraine first day of week is Monday but not Sunday

    By defaults in the calendar object obtained with locale ua_UA getFirstDayOfWeek
    () function return SUNDAY as a first week day... Java version is 1.3.1_01

    Answer: Yes indeed, according to this list:
    the first day in Ukraine is Monday. For those who does not know will say that in many countries Sunday or even Saturday is first day, for example in Egypt - Saturday and in Argentina and Brasil - Sunday...
    It was a bug since according to ISO 8601 in all European countries a week starts with Monday...
    I know that with Hungarian calendar was the same bug... In latest 1.4.1 and beyond the bug is fixed.

    Tip 3

    Good to know: Performance testing has shown that the finalize methods in the channel classes impose a significant GC penalty upon server-type programs that must deal with
    thousands of new open channels per second.

    And now in J2SE 1.4.2the finalize methods of the primitive channel classes (SocketChannel, ServerSocketChannel, etc.) have been removed . Additional performance test measurements revealed that the presence of these methods imposed a significant (factor of 100) garbage-collection penalty upon server-type applications that process thousands of new open channels per second. User code that deals in channels should be carefully written to close channels explicitly rather than rely upon the garbage collector to do so.

    Latest posts on our message board
    Trying to connect to mysql!?

    I´m trying to connect to a mysql database from a applet, but I get this error:

    Unable to connect to any hosts due to an exception:java.security.AccessControlException:access denied.....and so on.

    What´s that? It used to work in postgres.
    What should I do?

    please help here

    Java Layers

    I have a java menu, and also java visual effects on our logo. at http://www.blueislanddivers.com/testlogo.htm but cannot make the menu bar remain on top view over the logo. I'm more of a 'mechanic' than programmer, certainly not an expert. Any help would be greatly appreciated.

    Sean Mckenna

    please help here

    Connect 4 or 4 in a Row HELP


    I'm creating a school project, the game connect 4, or four in a row. I have everything done, except for where the program checks wether the

    lines are 4 in a row or not. Can anyone help? Here's the code:
    continues here

    Applet Menu

    I can't run one applet with a menu, where itemmenu don't call the function related.

    The same menu in the application fashion work, please help me and sorry for mi english

    please help here

    Parallel sorting

    I would like to send me (or give links) of java code
    relative to :
    sorting an array of integers in parallel
    please help here

    Almost no hair left! NullPointerException in EventDispatchThread.

    I get this error after app has been running a while.
    What is the problem and where can I fix? It doesn't happen on my dev machine, but only on the production system.
    Help will be much appreciated!

    continues here

     Printer Friendly Page  Printer Friendly Page
     Send to a Friend  Send to a Friend

    .. Bookmark and Share

    Search here again if you need more info!
    Custom Search

    Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

    RSS feed Java FAQ RSS feed Java FAQ News     

        RSS feed Java Forums RSS feed Java Forums

    All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

    Interactive software released under GNU GPL, Code Credits, Privacy Policy