wood burning stoves 2.0*
The moose likes Mac OS and the fly likes Swing Apps Hang Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "Swing Apps Hang" Watch "Swing Apps Hang" New topic
Author

Swing Apps Hang

Rob Saul
Greenhorn

Joined: Jul 18, 2005
Posts: 7
At some point in the recent past Swing apps started hanging. Unfortunately, I'm not sure if
this started with a 10.3 update or with Tiger.

At first I thought it was something wrong with jEdit. So I made sure I had the latest stable.
Same problem. I get the app name showing up in the menu bar, but no further progress.

As a test I tried both a Swing and a SWT 'HelloWorld' program. The former would just
hang, requiring killing, and the latter worked fine. I guess this explains why Eclipse works.

Sadly this keeps many useful programs from running, including Java Preferences.

Any suggestion on how to fix this would be much appreciated.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Well, since Swing implementation is platform-specific, I'm guessing that you're seeing something unique to the Mac version of Java you're running. If that's the case, then you might want to change the version you're using -- at least to see if this corrects the problem.

If I'm not mistaken, the Java Preferences app is new with Apple's Java 1.5, so I'm assuming that you have the new 1.5 download. However, 1.4.2 remains the default after downloading 1.5. To change your runtime version, Apple wants you to use that Java Preferences app. (To change your development version, you need to use Terminal to change the CurrentJKD alias.)

So the questions are:
1) What do you get when you type "java -version" (without quotes) in Terminal?
2) What versions do you have installed under /System/Library/Frameworks/JavaVM.framework/Versions?
3) Once we know the answers to the first 2 questions, how can you change the version without using the Java Preferences app? I suspect this will require using Terminal to change some aliases.
[ July 20, 2005: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Rob Saul
Greenhorn

Joined: Jul 18, 2005
Posts: 7
Originally posted by marc weber:
Well, since Swing implementation is platform-specific, I'm guessing that you're seeing something unique to the Mac version of Java you're running. If that's the case, then you might want to change the version you're using -- at least to see if this corrects the problem.

If I'm not mistaken, the Java Preferences app is new with Apple's Java 1.5, so I'm assuming that you have the new 1.5 download. However, 1.4.2 remains the default after downloading 1.5. To change your runtime version, Apple wants you to use that Java Preferences app. (To change your development version, you need to use Terminal to change the CurrentJKD alias.)


Yes, the Java Preferences app is new with 1.5.


So the questions are:
1) What do you get when you type "java -version" (without quotes) in Terminal?

java -version
java version "1.4.2_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_07-215)
Java HotSpot(TM) Client VM (build 1.4.2-50, mixed mode)


2) What versions do you have installed under /System/Library/Frameworks/JavaVM.framework/Versions?

Contents of /System/Library/Frameworks/JavaVM.framework/Versions/:



3) Once we know the answers to the first 2 questions, how can you change the version without using the Java Preferences app? I suspect this will require using Terminal to change some aliases.


Looking about in /System/Library/Frameworks/JavaVM.framework/ and
/System/Library/Frameworks/JavaVM.framework/Versions I see things are sym linked
around. And /usr/bin/java is a link to /System/Library/Frameworks/JavaVM.framework/Commands/java. Of course Commands is just a sym link to Versions/CurrentJDK/Commands.

Changing CurrentlyJDK to point to 1.5 seems simple enough. I wonder about Current, though, as it points to A (see above directory listing). This seems to affect JavaVM, Headers, and Resources in /System/Library/Frameworks/JavaVM.framework/ which are all links to their counter parts in /System/Library/Frameworks/JavaVM.framework/Versions/Current/.

I have no problem mucking about on the command line ( been doing it for years ), but I don't want to end up with my system in a worse state than it's already it. :roll:

Thanks,
~Rob
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Rob Saul:
...I don't want to end up with my system in a worse state than it's already it. :roll:

Absolutely. And I'm not so sure what the role of that "A" directory is. (Anyone...?)

I'm at work now, so I don't have a Mac in front of me. Let me check where all of these aliases are pointing, and then see what changes when I use the Prefrences app to switch runtime environments.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Under JavaVM.framework, I have...

Versions - folder
Resources - alias to Versions/A/Resources
Libraries - alias to Versions/1.5.0/Libraries
JavaVM - alias to Versions/A/JavaVM
Home - alias to Versions/1.5.0/Home
Headers - alias to Versions/A/Headers
Commands - alias to Versions/1.5.0/Commands
Classes - alias to Versions/1.5.0/Classes

Under Versions, I have...

CurrentJDK - alias to 1.5.0 folder (I set this via Terminal)
Current - alias to A folder
A - folder
1.5.0 - folder
1.5 - alias to 1.5.0 folder
1.4.2 - folder
1.4 - alias to 1.4.2 folder
1.3.1 - folder
1.3 - alias to 1.3.1 folder

Here's what Terminal shows for java -version...

java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-56)
Java HotSpot(TM) Client VM (build 1.5.0_02-36, mixed mode, sharing)

The Java Preferences app says that, "Runtime settings are used when a Java application or applet is launched using the Java Network Launching Protocol (JNLP)." I'm not familiar with JNLP, but when I set it for 1.4.2, it didn't change any of the above.
[ July 20, 2005: Message edited by: marc weber ]
Rob Saul
Greenhorn

Joined: Jul 18, 2005
Posts: 7
Thanks for the info Marc.

By changing CurrentJDK to be a link to 1.5 I now have the latest Java(tm), but Swing stuff still isn't working. I tried starting in debug mode and attaching jdb, but got "Fatal error: Unable to attach to target VM."

This suggests the problem is independent of the jvm in use.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I'm thinking that you also need to change the aliases under JavaVM.framework in order to get a 1.5 runtime environment.

But .
[ July 21, 2005: Message edited by: marc weber ]
Rob Saul
Greenhorn

Joined: Jul 18, 2005
Posts: 7
Originally posted by marc weber:
I'm thinking that you also need to change the aliases under JavaVM.framework in order to get a 1.5 runtime environment.

But .


Actually, that shouldn't be necessary. The way the sym links ( or as you say, aliases ) work out the stuff in JavaVM.framework points to there equivalent in Versions/CurrentJDK. Of course, Versions/CurrentJDK just points the one of the actual jdks ( 1.5.0 in my case ). A few levels of indirection, but not that unusual a set up on a *nix type OS where several version of something are installed.

right now I'm looking at info generate by ktrace and kdump to see if there anything there that look odd.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Rob Saul:
... The way the sym links ( or as you say, aliases ) work out the stuff in JavaVM.framework points to there equivalent in Versions/CurrentJDK...

Hmmm... These are more dynamic than I realized. So when you changed CurrentJDK to point to 1.5.0, that also changed JavaVM.framework/Libraries to point to Versions/1.5.0/Libraries (for example)?
Rob Saul
Greenhorn

Joined: Jul 18, 2005
Posts: 7
Originally posted by marc weber:

Hmmm... These are more dynamic than I realized. So when you changed CurrentJDK to point to 1.5.0, that also changed JavaVM.framework/Libraries to point to Versions/1.5.0/Libraries (for example)?


Yep. Mind you, this sort of thing should be used with care, as it can lead to a tangle of links.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

...shades of goto
[ July 22, 2005: Message edited by: marc weber ]
 
Don't get me started about those stupid light bulbs.
 
subject: Swing Apps Hang