tom’s java applet

Tom:
I took a look at your code- seemed ok to me. Tried to pull the applet up in my browser at home: no dice. I am using Firefox with the nice Java console enabled. The error message the console was reporting was along the lines of the “class not found” variety. Looked again, and sure enough, no compiled binaries. Looked at the email and noticed that compiled binaries were not sent along. So compiling is in order:

My first attempt to compile was a bust:

[bturnip@electric-lash blackjack]$ javac Blackjack.java
Note: ./Hand.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

I didn’t feel like investigating the code, so I tried compiling with -Xlint:unchecked and everything went fine. Uploaded the whole kettle of fish to your java directory. Runs just fine, far as I can tell: Tom’s Blackjack Applet ver 0.01

This entry was posted in learning java. Bookmark the permalink.

24 Responses to tom’s java applet

  1. tjm says:

    Alright, see, it still doens’t run for me so it must just be a browser issue on my end. It’s good news in that I did it right the first time. It’s not good in that I apparently won’t be able to test anything since I probably don’t control the browser settings I need, but I’ll look into it. I can still use that appletviewer things, so I guess all is good. Thanks, and sorry if I didn’t mention that you would need to compile that stuff.

  2. bturnip says:

    Whoa- major newsflash! It doesn’t work. I don’t have an explanation. It worked fine at home (Linux/Firefox), trying both on the local disk and accessing the bturnip.com version. A quick test at work(Win XP), shows that it doesn’t work on IE or Firefox.

    Strange. IE, being the browser junk it is (a separate rant could be started here that its only real purpose was to crush Netscape, and, having fulfilled that purpose, is now pretty much ignored, development-wise. Which can be used to further the rant into how competition is good for the consumers and thus should be fostered, perhaps even through gov’t intervention…) Anyway, IE, being the browser junk it is, has nothing to say. Firefox fails, but the Java console is available, which spits out the following error message:
    java.lang.UnsupportedClassVersionError: Blackjack (Unsupported major.minor version 49.0)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at sun.applet.AppletClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadCode(Unknown Source)
    at sun.applet.AppletPanel.createApplet(Unknown Source)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(Unknown Source)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    More investigation later.

  3. tjm says:

    I get this error message when I click on the link with IE. This appears in a grayed-out box where the applet should be runnning.

    Java.lang.UnsupportedClassVersionError: Blackjack (Unsupported major.minor version 49.0)

  4. Danny says:

    OK, I am hoping to have more information soon, but I think I am getting a handle on the problem. The major.minor issue is because your applet is compiled with java 1.5. The browsers that are crapping out are running java 1.4.x or older.
    That makes sense to me- I can see the applet from home (from either my local disk or bturnip.com). No problem, because I have installed the new java runtime.

    At work, I have not installed the newer JRE, and your applet won’t work.

    What I think we need to do now is to find out if we can confirm this is the issue. I want to try to compile the applet with a jdk older than 1.5.

    If we can confirm this is the problem, we have to find out how to safely compile for 1.4 and 1.5 java jre’s.

  5. Danny says:

    OK- I still have access to the java compiler for java 1.4.2.

    I recompiled the Blackjack code. The 1.4.2 applet can be found here . I am eagerly waiting to hear if this “fixes” the problem.

  6. bturnip says:

    I have confirmed my suspicions. Using the java compiler for jdk 1.4.2 results in an applet that works on both IE and Firefox on my Windows machine at work, which is running a pre-1.5 version of java. So the 1.5 compiler somehow breaks backwards compatibility.

    The next step is to figure out how to continue to use the 1.5 platform and still compile applets and the like that will work on older java platforms. I have a lead on that already with a sourceforge project called Retroweaver . I haven’t tried to actually use it yet, but it looks promising.

    For me, it isn’t a huge burden (yet) to recompile with an older compiler, though I imagine this won’t be the case for long.

    My question to you, Tom, would be what version of Java are you running on your machine at home? Did you install the 1.5 development kit and the JRE?

  7. tjm says:

    Bad news, it still doesn’t work for me. I did install the 1.5 development kit and the JRE at home. Actually, I have the version that came with the Sams book (1.4.??) installed on my old computer downstairs so I could try that too. It recommended downloaded 1.5 from Sun but I’ve got dial-up on that box so screw that.

    Note also that this may work for me from home, but it’s the same gray box on IE from work. I wonder what exactly is compiler dependent in the code. If I could figure that out, I could just change the code.

    It also makes me wonder about Java. They sell it as being great because it’s platform independent, but the fact remains that the JVM has to know what platform it’s on and do different things on different platforms to run the code. That’s got to lead to a ton of platform-specific bugs, I would think.

  8. bturnip says:

    I might have misled you- the code isn’t compiler dependent at all. I didn’t make any changes to your code, all I did was use a different compiler. So the “bytecode” is platform dependent, I guess.

    More questions:
    Did you go to the new blackjack142 folder and try to run the applet there? I thought for sure it would be the answer to your problem.

    Were you able to see any error message on this retry? I would be very surprised if it was the same major/minor thing.

  9. tjm says:

    You’re right, saying the byte-code is platform dependent is better than what I said about it being compiler dependent. And no, I don’t see any error message now, it’s just a gray box. Might be something just in my browser, I’ll try from home.

  10. tjm says:

    Damn thing doesn’t work from home either. Same deal, just a gray box.

  11. tjm says:

    My applet doesn’t work in Foxfire either. It’s just a white box there with an icon that says “click to download plug-in” and when I click, a box pops up that says “no plug-in found” or something like that.

  12. tjm says:

    Incidentally, the same thing happens to me at radioio. It won’t work with Foxfire, says I need some plug-ins and when I try to download them it says “no suitable plug-ins found” (which is actually what it says with the blackjack applet too)

  13. Danny says:

    Can you try the “Tank Hunter” test and tell me what happens? This is definitely an unexpected stumbling block we have run across…

  14. tjm says:

    No dice. Says I need plug-ins and when I try to install I get “no suitable plug-ins found.”

  15. Danny says:

    Does IE pass the “tank hunter” test?

  16. Danny says:

    Try this Mozilla support site for help installing and enabling Flash, Java, etc. Not sure if it will help in your case, but it is a start. I don’t have a Windows machine at home to help with, unfortunately. I want to build one, but the money isn’t there yet.

  17. tjm says:

    Yeah, works with IE. I’ll check out the support site.

  18. tjm says:

    That’s got it mon copain. Not only does all the Java stuff work in Foxfire now, including the blackjack applet, but it also works in IE now with the stuff I downloaded from that support site. I can close the book on this one.

  19. tjm says:

    Eh hou, je suis alors! I jumped the gun, radioio still doesn’t work in Foxfire.

  20. Danny says:

    Well, I am not too surprised to hear that firefox doesn’t play nice with radioio. I have the same experience, even at work. I use IE. Not my preferred solution, but I haven’t invested the time in investigating the problem. Another project for another day.

    I am glad we can be done with this issue. Ready to move on- did you set up a RSS feed reader yet?

  21. tjm says:

    Yeah, I pretty much decided I’ll just use IE for radioio too. I’ve downloaded and installed enough stuff in the past two days. I am surprised that tank game worked in IE and not the simple little blackjack applet, then downloading that stuff fixed the blackjack applet. It makes me wonder what’s so weird about that code, but I’ll just have to write that off to one of many unexplained mysteries of the universe. Maybe I just had some old version of Java running with IE and this forced it into some kind of update and I picked up a bug fix or something.

    As for RSS – I was playing around with Sage a bit, but nothing too extensive yet. I had no problem setting it up with slashdot.org but it wasn’t as straight-forward to me how to do it with other sites, like this one for example. I really only tinkered with it for a few minutes though, so I might be able to figure it all out.

  22. GregJ says:

    It’s nice to see that you guys with all your various whack browsers are all finally giving up and using Internet Explorer, which seems to be working for just about everything you are trying to do. Bill Gates wins again. Mooowahahaha!!

  23. tjm says:

    And thanks to IE I removed 146 instances of spyware on my computer this weekend alone. I even got my normally Bill Gates dependent wife to ask me why we haven’t been using Firefox all along because she likes it that much better than IE.

    In a broader sense, I disagree with the theory that we should all just mindlessly use Microsoft stuff because it’s all heading to that anyway. You’re right that it’s about standardization, and that’s all anyone else is asking for in this realm. The stuff that should be standard works fine on any browser, it’s only stuff that Microsoft goes out of their way to screw up that doesn’t work elsewhere. Bill Gates is the one battling against standardization.

  24. Danny says:

    Well, against anything but Microsoft standardization.

    Whatever. If the people want crap, if it makes them happy, so be it. Denial and the placebo effect will keep them going. Now that IE is down to only 92% or 95% of the market share, Microsoft will prolly release a new version of the browser with some more stuff integrated in. They will prolly try to assert some submarine or other vauge patent at the same time.

    People will prolly be impressed- “Well Firefox doesn’t burn my cd’s, why would I want to use that?” Good for them, good for spyware and virus writers. Win/Win.

    I am taking myself out of the game. Good software will be available for me to us irregardless. You can drag a horse to water, but you can’t make it drink. World, you are on your own.

Leave a Reply

Your email address will not be published. Required fields are marked *