Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 26, 2008, 10:40 AM   #1
briantology
macrumors 6502
 
Join Date: Jun 2006
How to preview a Swing Applet?

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?
briantology is offline   0 Reply With Quote
Old Feb 26, 2008, 02:10 PM   #2
jchull
macrumors newbie
 
Join Date: Sep 2006
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
jchull is offline   0 Reply With Quote
Old Feb 26, 2008, 04:48 PM   #3
toddburch
macrumors 6502a
 
Join Date: Dec 2006
Location: Katy, Texas
Send a message via AIM to toddburch Send a message via MSN to toddburch
What exactly happens in Terminal when you enter "appletviewer appletname.java" ?

Post your hello world example here and I'll try it.
toddburch is offline   0 Reply With Quote
Old Feb 26, 2008, 11:05 PM   #4
briantology
Thread Starter
macrumors 6502
 
Join Date: Jun 2006
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
briantology is offline   0 Reply With Quote
Old Feb 26, 2008, 11:23 PM   #5
bloomberg
macrumors newbie
 
Join Date: Sep 2007
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.
bloomberg is offline   0 Reply With Quote
Old Feb 26, 2008, 11:49 PM   #6
briantology
Thread Starter
macrumors 6502
 
Join Date: Jun 2006
Wow, that was it. Nice and easy. Thanks bloomberg!
briantology is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Cannot get Java Applet copy/paste to work Wreckie OS X Mavericks (10.9) 2 Feb 17, 2014 09:11 AM
Java applet won't run tnsmart OS X 10.8 Mountain Lion 4 Jan 10, 2013 03:38 AM
Java applet not working - anything obvious I have missed? kdum8 Mac Basics and Help 33 Oct 26, 2012 03:06 AM
Free VNC with Java Applet CasuallyAwesome Mac Applications and Mac App Store 1 Aug 4, 2012 02:45 PM

Forum Jump

All times are GMT -5. The time now is 07:47 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC