Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
How to convince my parents to let me buy a 17" MacBook Pro Ulf1103 Buying Tips and Advice 58 Nov 27, 2013 11:45 AM
Tutorial: How to get PCSX2 to run on Mac (without BootCamp) Mirrors Mac Applications and Mac App Store 22 Jun 14, 2013 08:19 PM
IPHONE 4 how to JAILBREAK AND UNLOCK bs2511feist Jailbreaks and iOS Hacks 6 Apr 14, 2012 05:52 PM
Does anybody know how to get TweetTask? xmelissaxmayhem Jailbreaks and iOS Hacks 3 Jul 3, 2011 01:21 AM
[HOW TO] DIY iPhone 4 Swivel Car Mount QuarterSwede iPhone Accessories 13 Mar 8, 2011 02:51 PM


All times are GMT -5. The time now is 10:28 PM.

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

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