General discussion

  • Creator
    Topic
  • #2187794

    Simple applet won’t run – please help

    Locked

    by madestroitsolutions ·

    Hi all,
    I am an experienced programmer trying to learn Java. I have a very simple applet that I cannot get to run for some reason. Please see the code below:

    import java.applet.*;
    import java.awt.*;

    public class BLinkJVerCheck extends Applet
    {
    private Label m_labVersionVendor;
    public void init()
    {
    Color colFrameBackground = Color.pink;
    this.setBackground(colFrameBackground);
    m_labVersionVendor = new Label (” Java Version: ” +
    System.getProperty(“java.version”) +
    ” from “+System.getProperty(“java.vendor”));
    this.add(m_labVersionVendor);
    }
    }

    As you can see, this a pretty simple, straight forward applet, but for some reason when I attempt to run it on a web page, I get the following error (when I put the mouse on top of the square the applet is supposed to draw):

    load: class BLinkJVerCheck not found

    The tag on the web page:

    The applet file IS sitting in the same folder as the web page that calls it. When I compile the applet, everything goes ok, I get no errors and the class file is generated.

    Any ideas….???… I always found Java annoying, and now that I finally want to make the move, I cannot get a stupid applet to work… please HELP!

    Thank you in advance!

All Comments

  • Author
    Replies
    • #3248701

      Reply To: Simple applet won’t run – please help

      by tony hopkinson ·

      In reply to Simple applet won’t run – please help

    • #3247310

      Reply To: Simple applet won’t run – please help

      by martin simons ·

      In reply to Simple applet won’t run – please help

      If you are using Internet Explorer to view this
      applet, you will probably need to compile this
      using the option “-target 1.1”. And, if you are
      using jdk 1.5 (5.0) you will probably not be able
      to use this option.

      • #3261016

        Reply To: Simple applet won’t run – please help

        by madestroitsolutions ·

        In reply to Reply To: Simple applet won’t run – please help

        Thank you for replying. Yes, I was not able to compile it with that option on 5.0
        I did try it with 1.4.x though. The compiler yields no errors but the appletviewer does not launch and the applet does not load on the page.

    • #3247308

      Reply To: Simple applet won’t run – please help

      by debfar ·

      In reply to Simple applet won’t run – please help

      I just copied your Java code then compiled it,
      then I created a simple HTML page and pasted your applet tag into the page. And guess what?
      It works just fine through my IE browser.

      Here is what I have on my simple HTML page:
      —————–

      Applet
      Applet


      —————–

    • #3247304

      Reply To: Simple applet won’t run – please help

      by tarzanek ·

      In reply to Simple applet won’t run – please help

      Hi there,
      actually your java code is OK along with the html page tag. I am running WINXP with JAVA5 installed & the applet made from your article was running fine. I suppose the problem is elsewhere. Probably bad instalation of JDK or browser plugin. Try setting CLASSPATH (mine is not set & still the applet works) or checking whether there couldn’t be some browser related problems.

    • #3247300

      Reply To: Simple applet won’t run – please help

      by rafiq ·

      In reply to Simple applet won’t run – please help

      hi,
      your code looks ok. Why not you first try out the applet using AppletViewer before trying in the browser.

      hope this helps,

      rgds,
      Rafiq.

      • #3261070

        Reply To: Simple applet won’t run – please help

        by madestroitsolutions ·

        In reply to Reply To: Simple applet won’t run – please help

        Thank you for replying. I used the appletviewer and it doesn’t do anything. The command line executes but the appletviewer does not start, so I imagine something is wrong with the compiled code. Although your answer put me in the right direction, it still didn’t solve my problem. Your reply is very much appreciated, thanks again!.

    • #3247298

      Reply To: Simple applet won’t run – please help

      by cyberknault ·

      In reply to Simple applet won’t run – please help

      Okay, I am suspecting your class file format is not compatible with the VM you are running. If you are running your class in IE with Microsoft VM, try compile the source with target is 1.1.

      Hope this help.

      • #3261068

        Reply To: Simple applet won’t run – please help

        by madestroitsolutions ·

        In reply to Reply To: Simple applet won’t run – please help

        Thank you for replying. I tried your suggestion. The kit I am using does not allow compilation with target 1.1, I get the following error:
        target release 1.1 conflicts with default source release 1.5
        Thanks again!

    • #3247275

      Reply To: Simple applet won’t run – please help

      by sps1 ·

      In reply to Simple applet won’t run – please help

      This looks like a classpath problem. Setting your classpath to include the folder
      containing your class file may work, but some flavours of jre/vm have bugs/security
      issues that prevent this fix working.
      The only definitive diagnosis is to see what happens when you add your class file to
      one of the class libraries of your jre/vm – if it works, this is also the only fix until you
      install another jre/vm.

    • #3247262

      Reply To: Simple applet won’t run – please help

      by saurangshu ·

      In reply to Simple applet won’t run – please help

      Hi,

      This seems to be a classpath issue. Place your class in the defined system classpath and restart the browser.

      thx

    • #3247243

      Reply To: Simple applet won’t run – please help

      by deveshpradhan ·

      In reply to Simple applet won’t run – please help

      Use “-target 1.1” while compiling the code and I hope u will get rid of the issue. I tried your code and it was not working for me either.But then I compiled the code with “-target 1.1” option and it was running successfully.

      Usage:
      javac -target 1.1 BLinkJVerCheck.java

      Devesh

    • #3247221

      Reply To: Simple applet won’t run – please help

      by ravanibhavik ·

      In reply to Simple applet won’t run – please help

      May be u need to set the classpath in your Environmental Variable (classpath should be of your bin folder). Or u can put your .class file in your “bin” folder and run your applet from there.

    • #3247211

      Reply To: Simple applet won’t run – please help

      by mike ·

      In reply to Simple applet won’t run – please help

      Well, I’ve got good news, and bad news.
      The good news is, when I compile your example and duplicate your page, it works fine on my system, in both Mozilla and IE, under the exact conditions that you lay out. Bad new is that doesn’t get us any closer to fixing your problem. When I tried to load the applet in IE, I got security errors, service pack 2 still thinks java is the greatest threat known to mankind, so if you have alerts turned off that could be the problem. Which version of Java and the plug-in are your using? I know that older versions of Java under IE had problems with the applet tag, you had to wrap it in an object tag, but newer ones should do fine.
      hth
      Mike

      • #3261011

        Reply To: Simple applet won’t run – please help

        by madestroitsolutions ·

        In reply to Reply To: Simple applet won’t run – please help

        Thank you for replying. From many other tests I have conducted following other posts’ advice, I have come to the conclusion that this is not browser (or code, JAVA or HTML) related. It has to do with compilation, but I still can’t figure it out.

    • #3247166

      Reply To: Simple applet won’t run – please help

      by mjremijan ·

      In reply to Simple applet won’t run – please help

      I tried what you gave on FireFox and IE on Windows XP and had no problems. You’d need to post more information about your setup if it’s still not working.

    • #3247161

      Reply To: Simple applet won’t run – please help

      by charles simon ·

      In reply to Simple applet won’t run – please help

      I would strongly urge you to not use the Microsoft JVM. It is very old and has many bugs/limitations. Use the current Java version from Sun.

      If you must use the MS JVM then you will need to compile the applet code to be compatible with Java 1.1 as mentioned in some of the other comments.

      Last but by far not least is, to use the Java plugin, you will need to verify that your IE security settings do not disable scripting and Active-X controls. The best setting is to have it prompt you, then you will know if the plugin is actually starting.

    • #3247160

      Reply To: Simple applet won’t run – please help

      by georgehsnyder ·

      In reply to Simple applet won’t run – please help

      You’re running in a browser, Your browser is configured to look for classes in a specific directory. If your browser thinks /this/html/dir is the root dir it can not access anything not below /this/html/dir. This keeps users from browsing your system. It also means you have to have classes in the correct CLASSPATH. Check your environment variables.

    • #3247157

      Reply To: Simple applet won’t run – please help

      by alexmy ·

      In reply to Simple applet won’t run – please help

      Try to use codebase attribute in applet tag.

    • #3247145

      Reply To: Simple applet won’t run – please help

      by fipilica ·

      In reply to Simple applet won’t run – please help

      On my computer win 2000 it works like a charm.
      I suggest to specify a package and put that class into a .jar file. The html file may look like this:


      <br /> HTML Test Page<br />





    • #3246372

      Reply To: Simple applet won’t run – please help

      by jimmydevenport ·

      In reply to Simple applet won’t run – please help

      I got it to load fine using appletviewer: create web page with tag as you list, but make it HTML 3.2 (with ending tag instead of XHTML… then load appletviewer test.html or whatever you called your html file. Then I loaded that using Firefox 1.0 (moz 1.7.5 core, Windows XP SP2) and it worked fine… is the problem with IE? Mozilla? Also see HTMLConverter which comes with the JSDK – that may help you convert the applet so it works on various browsers … but sometimes it is buggy also… the best best is to make sure you have the latest JRE installed and “plugged in” to the browser… also see the Java Plug-in settings via your Windows control panel…

    • #3246250

      Reply To: Simple applet won’t run – please help

      by ncaajam ·

      In reply to Simple applet won’t run – please help

      I played with javabeans as a proof-of-concept for a project I worked on a while back that captured JPGs of screens as the user navigated our internal web site.

      I have an HTML file with






      in it and the file BLinkJVerCheck.class is in the same directory. It worked fine.

      Is it possible that you have the class file somewhere the classpath can’t find it?

    • #3244689

      Reply To: Simple applet won’t run – please help

      by clgan333 ·

      In reply to Simple applet won’t run – please help

      Your java code is fine but when I test it on Java Beans for Sun, it fails as what is shall get. I think you’re use some Java SDE tool to test the code. But when I use normal procedure to test it, it works properly. I do agree with the classpath problem.

      I found your code is not in constantly implement the coding convention, please notice
      that the ***m_labVersionVendor*** and ***colFrameBackground***, one use Hungarian prefix and other no… I guess you are VB programmer. Someone do argue about to place the prefix for the variable, lengthy work and cumbersome to do some. But for me, I preferred to use Huangarian prefix since it will reveal the scope of variable which I deal with.

      Proposal: use ***m_labVersionVendor*** for class scope and ***l_colFrameBackground*** for local scope, and g_intCounter for global scope of convention, it show stringent software engineering practice…

      • #3261062

        Reply To: Simple applet won’t run – please help

        by madestroitsolutions ·

        In reply to Reply To: Simple applet won’t run – please help

        Thank you for replying. The code is not mine. I actually got it from a web site. I use Hungarian too. I need to get this running by tomorrow and I still haven’t been able to make it work. I am doing a fresh installation of J2SE JDK 5.0 Update 3 on another machine….

    • #3244440

      Reply To: Simple applet won’t run – please help

      by ablake1 ·

      In reply to Simple applet won’t run – please help

      You haven’t specified the codebase property of the applet tag in your html file. This property should specify the path to your applet’s jar file.

    • #3243203

      Reply To: Simple applet won’t run – please help

      by ablake1 ·

      In reply to Simple applet won’t run – please help

      You haven’t specified the codebase property of the applet tag; the value should be the path to the applet jar file.

    • #3261759

      Reply To: Simple applet won’t run – please help

      by g… ·

      In reply to Simple applet won’t run – please help

      I saw a some funny things in there but there’s only one problem and it’s that you don’t have the right path to your applet. usually it helps if you put the path INCLUDED the package of the applet and, if you’re copying your applet, remember to copy the .CLASS and NOT the source. You need the compiled version of you code.

    • #3242014

      Reply To: Simple applet won’t run – please help

      by g… ·

      In reply to Simple applet won’t run – please help

      Do you have de BLinkVerCheck$1.class in the same directory?

    • #3241982

      Reply To: Simple applet won’t run – please help

      by tarzanek ·

      In reply to Simple applet won’t run – please help

      🙂
      already happened to me … got some conflicts between 1.4.2 & 5.0 installations of jdk
      heh … btw. unfortunately some code in java is written for a special version of jre … e.g. hibernate 2.1 got some serious problems running with 5.0 (at least examples) … don’t know about 3.0 but such a thing could really upset you
      hmm … it’s quite easy to run separate version of jre in java IDEs for separate projects, that’s why it should be possible to set up one main new system JRE & still have the possibility to switch to the old one … but … sometimes it’s quite a hack to accomplish it 😀 (at least in m$ win … reinstall is really necessary … but linux … symlinks rulez ;-D )

      • #3241917

        Reply To: Simple applet won’t run – please help

        by madestroitsolutions ·

        In reply to Reply To: Simple applet won’t run – please help

        Thank you for your help. I appreciate it. For everyone out there, thank you again. In the end, the problem turned out to be some kind of misconfiguration because I had 4 different versions running on the same machine. I still can’t get the appletviewer to load the applet, but at least the applet now works on the page. I have tried time and time again to get into Java but this latest incident has proven once again that this is just not for me. Much respect to everyone out there who does Java but personally I think it is a piece of junk. (maybe it is just frustration…)

    • #3241916

      Reply To: Simple applet won’t run – please help

      by madestroitsolutions ·

      In reply to Simple applet won’t run – please help

      This question was closed by the author

Viewing 24 reply threads