Easy to Learn Java: Programming Articles, Examples and Tips

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

Home

Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips

Books

Submit News
Search the site here...
Search...
 
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: 175

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


Bookmark and Share

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

Issue No: 175 22 July 2003
13770 subscribers

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

In this issue:
  • 1. If I run my applet with the SUN VM I get exception: "Either "code" or "object" should be specified, but not both."
  • 2. Why wait(), sleep(), notify(), notifyAll() must be inside a synchronized block, otherwise...
  • 3. In releases prior to 1.4.2, it was possible to create an invalid URL instance such as the following: new URL...
  • 4. Latest posts on our message board
  • 5. Link to Java FAQ

  • Hello dear friends!

    Tip 1

    Question: If I run my applet with the SUN VM I get exception: "Either "code" or "object" should be specified, but not both." It does not happen with the Microsoft VM.

    Answer: I found good recommendations on Sun’s website about how to install latest browsers and avoid possible problems with running applets in different browsers:
    "This is a compatibility issue. To avoid the exception with the Sun VM, do not use an attribute named object with the PARAM element in an applet.
    For Netscape 7, or Mozilla 1.1 or later, running on Microsoft Windows, the browser will always use Sun's latest JRE—even if you have deselected the "Netscape 6 or later" or "Mozilla 1.1 or later" check box in the Browser tab of the Java Plug-in Control Panel. This is due to the auto-scan features of these browsers. For instance, if Netscape 7 is installed on a Windows machine that has Sun's 1.4.2 JRE installed as the latest version and you deselect "Netscape 6 or later" in the Control Panel, Netscape 7 will still run Sun's 1.4.2 JRE (Java Plug-in).

    Using Java Plug-in 1.4.2 in conjunction with Netscape TM 6.x browsers can cause erratic behavior, including closure of the browser window, for applets that invoke applet functions from JavaScript. This problem is due to a bug in the browser, and you can avoid this problem by using Netscape 7.0 browsers.

    The Netscape 7 installer provides three choices for installation: Recommended, Full, and Custom. The Java Plug-in may not work properly in Recommended or Full installations of Netscape 7 browsers. Such Netscape 7 browsers may close when attempting to launch an applet. To avoid this problem, install Netscape 7 using the Custom option, and choose not to install the Quality Feedback Agent.

    When installing Java Plug-in, it is necessary to shut down and then restart your web browser. On Microsoft Windows platforms, Netscape 7 has a Quick Launch feature that keeps it running in the background so that it can be launched with minimal start-up time from a Quick Launch icon in the system tray. To completely shut down Netscape 7, you must exit Netscape 7 from its Quick Launch icon in the system tray. "

    This tip is based on:
    http://java.sun.com/j2se/1.4.2/relnotes.html#vm

    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: Why wait(), sleep(), notify(), notifyAll() must be inside a synchronized block, otherwise it throws java.lang.IllegalMonitorStateException: current thread not owner.

    Answer: Wait/notify unlocks the monitor and it is not synchronized another thread can try to access it and start a race condition.


    Tip 3

    Good to know: In releases prior to 1.4.2, it was possible to create an invalid URL instance such as the following: new URL ("http://www.foo.com:-1/index.html").

    Specifying a port number of -1 is not valid. However, in previous releases the -1 was stripped off when sending such URLS with HTTP commands. In 1.4.2, the -1 is left in the URL and this may cause problems for some HTTP servers or proxies.

    Applications should not create URL instances with a -1 port number. Assuming the -1 refers to the default port in this example, the correct way to create this URL is new URL ("http://www.foo.com/index.html"). This note only applies to the single argument URL constructor.

    FREE Your PC From Corrupt Files Now!
    Have the peace of mind knowing your computer is automatically kept
    error-free, 24 hours a day! Safe. Simple. Secure. Silent. This proven,
    automated, and easy-to-use PC health check tool is guaranteed to
    instantly expose harmful files lurking on your computer.

    Get your FREE PC Health Check today at:
    http://mocda1.com/1/c/52983/80159/286358/286358


    Latest posts on our message board
    Getting Java to work in OS 9 - is this possible?

    My site is not up yet but there is another that uses a similar code:
    www.angelofjoy.com if you want to view it.

    I know that OS X is fully Java compatible, and that if it is not there are downloads available, but is this the case for OS 9?

    Please help me as I really want to be able to use Java and Javascript on my site!
    please help here...

    Frame speed

    I'm making a 2d game with Java2D. But i'm only getting 14 frames per second, how can I speed up image-drawing performance?
    please help here...

    Policy File Troubles

    I have an unsigned Applet which I need to grant permissions to in the policy file. The permissions I grant work fine, until I change the codebase. If i have it set to <all> then the applet runs perfectly, If I have it set to "file:/C:/ILO/*" Then it errors with a access denied (java.net.SocketPermission.... Error.

    all of the .class files are located in the C:ILO folder, any ideas on why the codebase path wouldn't work. I really dont want to give all applets the same permissions as this one, as it also reads and writes files.

    any ideas would be appreciated
    -tblank
    please help here

    FileSystemView

    Hi,
    I' ve noticed that when i search for a file in JFileChooser i can see views like My Computer, My Network Places etc and select them.
    I have my own file browser, but i can't take these views. I know that the problem is FileSystemView or WindowsFileSystemView but -till now- i didn't find any way to use these classes.
    Does anybody has any idea?
    Thanks.
    please help here

    Java noob question

    I have an html page....that is used only to launch the following javascript (which spawns another html page - brochure.html).

    heres the HTML:
    continues here...

    help with JPanels

    i have a JPanel with a picture in the middle and two JButtons at the bottom. One JButton changes the background color and the other one draws a circle around it. I have made two classes extending JPanel, one adds an image and listens for color change button. the other class draws the shape but the problem is that both the image and the shape have to be in the center of the frame. When i try to add shape panel to frame it overwrites the image panel. how can i show the image panel and shape panel at the same time and in the middle.
    many thanks!
    please help 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