Well, the settling down process, I guess indeed is related to threads.
There is a main thread and AWT thread. And main thread needs to be
taken out of the loop--pun intended.
I suspect J may still run initialization
on the main thread. Instead, the main
thread must only have one statement to invoke the rest of the code on AWT
thread. Can we confirm that?

Here is some insight. I just had the same issue with Native OpenGL in Java.
The initial demo was done in Jdk 1.4 and it didn't have the issue.
Then when updated resently, the issue appeared. The only factor is 
default Mac JVM is 1.5 now.
Providing the above pattern immediately fixed it.
So, it needs to be tested on 1.5.
See how main looks there.


Oleg


On May 7, 2008, at 10:49, "Eric Iverson" <[EMAIL PROTECTED]> wrote:

I doubt the problem has to do with threads. The javametrics are aquired in a 
non-AWT loop that sleeps until the AWT thread has settled down and the required 
info is available. My quess is that the loop is allowed to time out to early in 
Norman's situation. There would be no harm in increasing the time allowed and 
when I get a chance I will provide a version that simply waits longer to see if 
that fixes the problem. Java initialization from scratch is a surprisingly long 
winded process.

----- Original Message ----- From: "Oleg Kobchenko" <[EMAIL PROTECTED]>
To: "General forum" <[email protected]>
Sent: Tuesday, May 06, 2008 11:05 PM
Subject: Re: [Jgeneral] Further on "Failed to get Java metrics" error and 
asimple workaround


It is commandable to do this research, but...

Splashes are annoying. So is it worth replacing one annoyance
with another?

It was noticed earlier that there may be an issue with accessing
AWT from main thread.

So maybe this route can be pursued first?

Oleg


On May 6, 2008, at 19:45, "N. Drinkwater" <[EMAIL PROTECTED]> wrote:

Several posts last month reported that starting J 6.02 on OSX resulted in an 
error message-"Failed to get Java metrics." Although this error is a minor 
annoyance when running the IDE, it would be potentially very confusing for end 
users of standalone applications.

Investigating the problem further, I found that the error occurs the first time 
J is started after every reboot. I've only encountered the error on OSX 10.4 
(PPC) and 10.5 (Intel), both running Java SE 5. I had no problem running on 
linux (Ubuntu 7 and Fedora 8, Java SE 6). The error does not occur if any java 
program is run prior to starting J (including the prior failed attempt to start 
J).

As a simple workaround (until either Java on OSX or j.jar is fixed), a simple 
"splash screen" program can be inserted into the jwd script just prior to the 
execution of J. With the addition of the splash screen, the Java metrics error 
does not occur (even after a reboot) with the cost of a few seconds additional 
startup time. The change to the startup isn't worthwhile for users of the IDE 
who don't turn their computer off very often, but if you're distributing a 
program for use by non-J programmers it may be worth consideration. The revised 
start up script and java class for the splash screen are given below.

Norman Drinkwater

The revised jwd script is as follows (the last two lines are a single line of 
code):

#!/bin/sh
# problems - see J bin/install.htm
cd "`dirname "$0"`/.."
java -jar bin/Splash.jar
java -Xss8000000 -Xdock:name=J -Xdock:icon=bin/icons/jred.icns  -jar bin/j.jar 
"$@"

The splash screen is adapted from code in a book on Swing by Loy et al.
(I don't do Java, only J these days, so others may have a better solution.)

/*
SplashScreen.java
Based on Java Swing (2nd ed.), by Loy et al.
*/
// Displays a simple text splash screen and exits after two seconds.
//

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;

public class SplashScreen extends JWindow {
private int duration;

public SplashScreen(int d) {
 duration = d;
}

public void showSplash() {
 JPanel content = (JPanel) getContentPane();
 content.setBackground(Color.white);

 // Set the window's bounds, centering the window
 int width = 80;
 int height = 80;
 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
 int x = (screen.width - width) / 2;
 int y = (screen.height - height) / 2;
 setBounds(x, y, width, height);

 // Build the splash screen
 JLabel logo = new JLabel("J",
     JLabel.CENTER);
 logo.setFont(new Font("Serif", Font.BOLD, 72));
 logo.setForeground(Color.red);
 content.add(logo, BorderLayout.SOUTH);

 // Display it
 setVisible(true);

 // Wait a little while
 try {
   Thread.sleep(duration);
 } catch (Exception e) {
 }

 setVisible(false);
}

public void showSplashAndExit() {
 showSplash();
 System.exit(0);
}

public static void main(String[] args) {
 SplashScreen splash = new SplashScreen(2000);
 splash.showSplashAndExit();
}
}
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm



____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now. 
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm



      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to