Results 1 to 16 of 16

Thread: A really simple (I hope) question

  1. #1

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    My browser can't find my .class file. I recently made an applet in java and was curious to see what it would look like in a web page. Well, whenever I load the HTML page, the status bar says the class isn't found. Is there an easy way to fix this, or am I missing something obvious?

    Code:
    <applet code="classname.class" width="335" height="150"></applet>
    Alcohol & calculus don't mix.
    Never drink & derive.

  2. #2
    Guest

    Thumbs up

    Your CLASSPATH needs to be set "globally" for the browser, not just for the shell you develop code in.

    For Win 9X, set in AUTOEXEC.BAT
    For NT, set in "Environment" in "System" properties in "Control Panel".

    I assume if you set the classpath in a dos shell, then launch the browser from that dos shell it will be set for that browser session.

  3. #3

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    How would I go about doing that?
    Alcohol & calculus don't mix.
    Never drink & derive.

  4. #4
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Do you mean setting the -classpath?

    goto to start --> run --> --> then in the run box type in
    sysedit....... the system configuration editor shoud
    comeup with a bunch of windows inside of it... you only need the first window which is the autoexec.bat

    the firstline in the window shoud say somthing like
    set CLASSPATH=%CLASSPATH%;C:\jdk1.3\jre\lib\ext\jce1_2_1.jar;C:\jdk1.3\jre\lib\ext\local_policy.jar;C:\j dk1.3\jre\lib\ext\US_export_policy.jar;C:\sunjce_provider.jar;C:\Java;

    in a long line... if you notice the last line in my class path
    is C:\Java; that is where all of my classes are held.. add
    the directory that contains your classes so they can be found......

  5. #5
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Just wanted to say my path i really long because i have the JCE (Java Crypto Extension) installed yours probably
    wont be as long...... I noticed that it is also nessary to
    reboot your system for the changes to take effect....

  6. #6

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    So every time someone wants to see a page with a Java applet in it, they have to do this? I want to put it in a web page so other people can see it, but I tested it out first and it wasn't working.
    Alcohol & calculus don't mix.
    Never drink & derive.

  7. #7
    Guest

    Thumbs up

    The Server (that which presents your classes to those interested in your classes) has to know where your classes are.

    When you develop on your private machine, you are the one that is being "served" the applet. So you may "point" to your local class directory/folder (i.e. set the classpath to your local directory). When you put this on a web server, you must "inform" that server how to find your classes as well. So you have to know where your web server looks for certain files (in this case, the class files), so that it can "serve" the public (whoever is your audience--intranet/internet).

    You can tailor this in an html page using a relative or absolute url that says where the applet class is.

    <HTML><HEAD><TITLE> A Simple Program </TITLE></HEAD><BODY>
    Here is the output of my program:
    <APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25></APPLET></BODY></HTML>

  8. #8
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    Do you have to have a Java Application server installed to run applets? Would it be possible to say run a Applet on a Geocities or tripod page?

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  9. #9
    Guest
    No application server is needed for applets.

    I would assume that you must be able to run applets from geocities. Your browser just needs to find the class file, then it gets downloaded to your pc, then your virtual machine (within your browser) runs the applet.

    You may not be able to "develop" the applets at a geocities' account, because it's like uploading any (html) file. If you had a shell account at your web host and you actually compiled the files there, then you'd have to set the classpath at that site, but all the browser needs is the url to find the class file to d/l and run on your browser.

  10. #10
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    so then why won't an applet work if you just put it in a folder on your desktop and call it with a HTML file?

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  11. #11
    Guest
    I think you can call an applet that way, you just have to have the browser find the class using the correct path. If your (web)server isn't setup to "see" that path, I think that is where the problem comes in.

    For instance, if I launch a dos shell and type "echo %classpath%" to look at my classpath, if I put an applet class in a folder not in that path, then I don't think the browser will load it unless I can put an absolute path to the class file in the html
    <APPLET CODE="c:\some\absolute\path\HelloWorld.class" etc

    and you might need \\ instead of \

    The URL for a local file, where instead of "http://" as the protocol, you use something like "file:///D|/delme/VPT.html" seems to only work for netscape in:
    <APPLET CODE="file:///D|/delme/VPT.class"

    I'd just set the global classpath (using autoexec.bat or the other methods shown in this thread) instead of a dos shell classpath.

    The bottom line is to inform the browser where the class file is. (i.e. HelloWorld.class).

    I suppose geocities can decide not to server class files even if they are in the same folder as html files which are allowed to be served, but I'm only guessing that they do allow applets.

  12. #12

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    I uploaded it to my geocities account and it still won't run. It still says it is not found. If you want to look at it to see if you can do anything go to http://www.geocities.com/darksaber_s...ava_guess.html.
    Alcohol & calculus don't mix.
    Never drink & derive.

  13. #13
    Guest

    Unhappy

    Thanks for the puzzle. Now this is going to be an itch for me too.

    I'm having problems with a simple hello world applet locally and at geocities with Internet Explorer version 4.72.

    BUT, my simple hello world applet works fine locally and at geocities with Netscape Communicator version 4.72.

    Again, my simple hello world applet works (locally) in appletviewer.

    Appletviewer complained about your java_guess.class, as well as IE when attempting to load the geocities page, but there was some "action" at your geocities site when loaded with Netscape (but not complete success).

    Appletviewer had the following kind words to say about your applet:
    java.lang.NoClassDefFoundError: java_guess (wrong name: day18/day18)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:11
    1)
    at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:142)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
    at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:108)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
    at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:366)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:579)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:515)
    at sun.applet.AppletPanel.run(AppletPanel.java:293)
    at java.lang.Thread.run(Thread.java:484)

    If this class stands alone, then you haven't done your part; but it could just be a browser issue.

  14. #14
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    Does anyone know how to get this working? I could really us it too !

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  15. #15
    Guest

    Unhappy

    Except for the error I posted above, Netscape works fine. It's IE that's giving me problems with applets.

  16. #16
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    ok, thanks

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width