Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

briantology

macrumors 6502
Original poster
Jun 5, 2006
289
0
I'm working on this Applet written in Swing, and for some reason I can't preview it using AppletLauncher, appletviewer, Safair or Mozilla. However, when I put it on a PC and open it in IE or Mozilla, it works. I've even tried testing a very basic swing applet that just says "Hello World", and it still doesn't work. I just get a box as the correct dimensions but with an X in the top left corner.
I'm running 10.5.2 and have Java 1.5.0_13. Any ideas on how I can view these Swing applets on OS X?
 

jchull

macrumors newbie
Sep 1, 2006
4
0
Applets are so 20th century. You should look at Java Web Start, or JSF+javascript to do what you are doing, if possible. Sorry I don't have the answer to your actual question
 

toddburch

macrumors 6502a
Dec 4, 2006
748
0
Katy, Texas
What exactly happens in Terminal when you enter "appletviewer appletname.java" ?

Post your hello world example here and I'll try it.
 

briantology

macrumors 6502
Original poster
Jun 5, 2006
289
0
Well, when I try: appletviewer simple.java
it sits there for a second, then just returns a new line.
But when I try: appletviewer simple.html
a window pops up, but at the bottom of the window it says "Start: applet not initialized."

Here is the simple applet code:
Code:
import javax.swing.*;
import java.awt.*;

public class simple extends JApplet {
	
	public void init() {
		JLabel label = new JLabel("Testing a Swing Applet");		
		setLayout(new FlowLayout());
		add(label);
	}
}

And this is the HTML file I've been testing with:
Code:
<html>
<head>
<title>Simple Applet in Swing</title>
</head>
<body>
<applet code="simple.class" width=200 height=50></applet>
</body>
</html>

Here's an error that pops up in the Java Console when I try to view the applet in a web browser:
Code:
java.lang.UnsupportedClassVersionError: Bad version number in .class file
 

bloomberg

macrumors newbie
Sep 8, 2007
25
5
java.lang.UnsupportedClassVersionError: Bad version number in .class file

This is thrown when class files are compiled with a different version of java (usually newer) than the one being used to run them. Did you update your jdk recently or move class files between computers? Try recompiling all your sources with your current jdk and try again.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.