This problem is especially annoying because it works on my computer. I think it has something to do with this computer being the one that it was compiled on...

Anyways, here's the page:
http://hp-h.com/p/gzero14/java/HydraSWApplet.shtml

Since I used basically the same html for some other applet and that one works, I think the problem lies in the java code...except I did everything according to the book so by all means it should work. I attached the java file...so if someone could take a look and point out what's wrong, I'd appreciate it.

Btw I have massive amounts of spaces in some of the labels because when the label gets set to something with more characters it gets cut off...don't know enough java to do it the real way (I'm assuming there is one...).

following the link, i get this. seems fine?

At first it didn't open, but I tried again and it did.
When it didn't open, I opened the java console and it gave this error message:

java.lang.UnsupportedClassVersionError: HydraSWApplet2 (Unsupported major.minor version 49.0)

	at java.lang.ClassLoader.defineClass0(Native Method)

	at java.lang.ClassLoader.defineClass(ClassLoader.java:502)

	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)

	at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:148)

	at sun.plugin.security.PluginClassLoader.findClass(PluginClassLoader.java:168)

	at java.lang.ClassLoader.loadClass(ClassLoader.java:299)

	at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:114)

	at java.lang.ClassLoader.loadClass(ClassLoader.java:255)

	at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:501)

	at sun.applet.AppletPanel.createApplet(AppletPanel.java:566)

	at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1775)

	at sun.applet.AppletPanel.runLoader(AppletPanel.java:495)

	at sun.applet.AppletPanel.run(AppletPanel.java:292)

	at java.lang.Thread.run(Thread.java:536)

java.lang.UnsupportedClassVersionError: HydraSWApplet2 (Unsupported major.minor version 49.0)

	at java.lang.ClassLoader.defineClass0(Native Method)

	at java.lang.ClassLoader.defineClass(ClassLoader.java:502)

	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)

	at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:148)

	at sun.plugin.security.PluginClassLoader.findClass(PluginClassLoader.java:168)

	at java.lang.ClassLoader.loadClass(ClassLoader.java:299)

	at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:114)

	at java.lang.ClassLoader.loadClass(ClassLoader.java:255)

	at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:501)

	at sun.applet.AppletPanel.createApplet(AppletPanel.java:566)

	at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1775)

	at sun.applet.AppletPanel.runLoader(AppletPanel.java:495)

	at sun.applet.AppletPanel.run(AppletPanel.java:292)

	at java.lang.Thread.run(Thread.java:536)

java.lang.UnsupportedClassVersionError: HydraSWApplet2 (Unsupported major.minor version 49.0)

	at java.lang.ClassLoader.defineClass0(Native Method)

	at java.lang.ClassLoader.defineClass(ClassLoader.java:502)

	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)

	at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:148)

	at sun.plugin.security.PluginClassLoader.findClass(PluginClassLoader.java:168)

	at java.lang.ClassLoader.loadClass(ClassLoader.java:299)

	at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:114)

	at java.lang.ClassLoader.loadClass(ClassLoader.java:255)

	at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:501)

	at sun.applet.AppletPanel.createApplet(AppletPanel.java:566)

	at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1775)

	at sun.applet.AppletPanel.runLoader(AppletPanel.java:495)

	at sun.applet.AppletPanel.run(AppletPanel.java:292)

	at java.lang.Thread.run(Thread.java:536)

I would suggest updating the JRE...If that doesn't work then try reinstalling both the jdk and jre and make sure on the jdk that you at least have version 1.4.2 or higher.

Yeah, that's what it's supposed to look like. I guess the applet is okay then o_O.
It runs fine on my home computer. On every other computer it doesn't work and it's really annoying...

Since I assume most computers have 1.4.2, and i have some version of 1.5, that might be the problem, though the book was written when it was 1.4.1 so that shouldn't be the problem.

I'll try putting it on another host later and see how that turns out.

http://www.geocities.com/applet.html

Asked someone to try it and it still didn't work.
Are both of you using JRE 1.5.0? I think that might be the problem but it shouldn't. Maybe it's something to do with compiling it using JDK 1.5.0, but shouldn't it be backwards compatible...*pulls hair out*

That's why I ask you to download the latest jre, was because of backwards capability...I have 1.5 and this works one time, then the next time it won't work.

I hate to ask this because you've probably already done it, but have you downloaded jdk 1.5 and recompiled with it?

I was compiling it with 1.5 all along, I was wondering if compiling it with 1.4.2 would make a difference and that doesn't make much sense :|.

Or maybe my install is just screwed up. At one point I had jre 1.5.0, then I had jdk 1.4.2, then I uninstalled everything and got jdk 1.5.0, and I made the program afterwards.

I know what it is now. It's your browser causing the trouble. I can view my applets in IE but as soon as I try to open them in FF it gives me the same error message you are getting. I believe the browser is not using the updated version. I'm going to find out how to do get it to work and get back to you.

If found it. Goto your control panel under add/remove programs. Uninstall all JRE's except for 1.5. If your like me you'll have to uninstall about 5 of them. After that it should work.

I don't think you get the problem, I have no problem viewing it, but other people can't see the applet.

Doesn't even work when I set up a computer that previously had no java with 1.4.2. I think I will uninstall 1.5.0 and try to compile it in 1.4.2 and see what happens (not like I'm using any new features this 1.5.0 might have anyways...)

Speaking of which, maybe someone else could compile the java and see what happens o_O. Maybe that's asking too much, I'll try 1.4.2 first.

I understand the problem, there could be several things happening.
First, find out what error message they are recieving by asking them to open up the java console...That should display the errors(that is of course if you have system.out.println() statements). Once you find out that your home free because you can simply search google to check what that error means.

Now one other common problem is the container. Older versions of java get mad if you don't use lines such as this:

getContentPane().setLayout(new FlowLayout());

instead of the newer supported ways:

setLayout(new FlowLayout());


I've seen that many times.


Anyways, let me look at the source code(if you don't mind) and I can tell you wether it's a coding problem or not.

I attached the code to the first post, you'll see that it is so freakishly simple that it shouldn't have any problems...

Edit: Well that's awesome. Downgraded myself to 1.4.2_08. Couldn't load my own applet. Recompiled with 1.4.2 and I can see my own applet again. Will ask a few people to check it out, but I think it was just the 1.5.0 compiler.

Where you add all those components, try this:

getContentPane.add(component);

instead of:

add();

That should make it more compliant, check that with the other computers.

By the way, if you want a better aligned applet you can use the setBounds() method align it wherever you want.

Thanks for the help.

I'll try your suggestions when I can, I just started learning Java recently so I have no idea how to use them right now :].

I can fix your applet for you if you like. I'll change it to swing and fix the alignment, and use statements that will be compliant will all browsers. I'm almost positve that this is what's happening, but it could turn out it's not.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.