where to host your applets

Hi, I tried to save an applet on my freewebs account so I could access it from anywhere in an html webpage, but for some reason it refuses to work.

Does anyone know how I can fix this? If not, do you know of a good, (free) place where you can upload java applets, and access them within an html webpage?

Btw, I'm also fairly new to java and to programming in general, so don't assume I know a lot. :-\

[423 byte] By [mikau16a] at [2007-11-27 4:50:35]
# 1
Applets are executed on the client and should require almost nothing in the way of special support from the server.Check the java console when you try to access the page with the applet. Perhaps it has a stack trace or another helpful error message.
paulcwa at 2007-7-12 10:03:58 > top of Java-index,Java Essentials,New To Java...
# 2
the exception thats thrown is a classDefNotFoundExceptionits just not able to access the .class file on my freewebs account. I checked repeatedly to make sure the adress was correct, I copied it directly from my freewebs account.
mikau16a at 2007-7-12 10:03:58 > top of Java-index,Java Essentials,New To Java...
# 3

> the exception thats thrown is a

> classDefNotFoundException

>

> its just not able to access the .class file on my

> freewebs account. I checked repeatedly to make sure

> the adress was correct, I copied it directly from my

> freewebs account.

Dunno if I'm telling you this right but, do you have FTP access to your freewebs account? I don't know much about freewebs as I use a paid-for website, so, ya.

And, how are you trying to save this applet exactly?

Zacha at 2007-7-12 10:03:58 > top of Java-index,Java Essentials,New To Java...
# 4

Can you access the applet directly? I mean if you type the applet's URL in to the browser's window, or by using a utility like curl.

Can you read the logs on the server? Do you see any entries indicating that something tried to retrieve the applet? If so, what was the response code and number of bytes returned?

Look at the stack trace again. Often somewhere in the middle it will give an earlier stack trace, indicating the actual problem. (for example, it couldn't open an HTTP connection, or the file returned was corrupted)

paulcwa at 2007-7-12 10:03:58 > top of Java-index,Java Essentials,New To Java...
# 5

again, I'm fairly new to this stuff, especially web programming so i don't fully understand some of your questions. :-(

I don't know what FTP accesss means so I'm not sure if I have it. :-\

If a file on freewebs is an image, you can view the image just by typing its url.

If I try to access a .class file though, nothing happens, but heck, nothing happens if you try to open a .class file

directly on your own computer, right?

here's my html code

<html>

<head>

<title> myTitle </title>

</head>

<body>

<APPLET CODE="http://www.freewebs.com/mikau16/JavaShapeArray4.class"></APPLET>

</body>

</html>

and here are the error messages:

Java Plug-in 1.5.0_06

Using JRE version 1.5.0_06 Java HotSpot(TM) Client VM

User home directory = C:\Documents and Settings\Rav

-

c:clear console window

f:finalize objects on finalization queue

g:garbage collect

h:display this help message

l:dump classloader list

m:print memory usage

o:trigger logging

p:reload proxy configuration

q:hide console

r:reload policy configuration

s:dump system and deployment properties

t:dump thread list

v:dump thread stack

x:clear classloader cache

0-5: set trace level to <n>

-

load: class http://www.freewebs.com/mikau16/JavaShapeArray4.class not found.

java.lang.ClassNotFoundException: http:..www.freewebs.com.mikau16.JavaShapeArray4.class

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)

Caused by: java.io.IOException: open HTTP connection failed.

at sun.applet.AppletClassLoader.getBytes(Unknown Source)

at sun.applet.AppletClassLoader.access$100(Unknown Source)

at sun.applet.AppletClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

... 10 more

load: class http://www.freewebs.com/mikau16/JavaShapeArray4.class not found.

java.lang.ClassNotFoundException: http:..www.freewebs.com.mikau16.JavaShapeArray4.class

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)

Caused by: java.io.IOException: open HTTP connection failed.

at sun.applet.AppletClassLoader.getBytes(Unknown Source)

at sun.applet.AppletClassLoader.access$100(Unknown Source)

at sun.applet.AppletClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

... 10 more

mikau16a at 2007-7-12 10:03:59 > top of Java-index,Java Essentials,New To Java...
# 6
Apparently it can't even open an HTTP connection (a basic, standard, web connection) to the class file.Are you sure your computer is connected to the net when you run this? Are you behind some kind of firewall?
paulcwa at 2007-7-12 10:03:59 > top of Java-index,Java Essentials,New To Java...
# 7

well when I open a .html file from mydocuments, I assume the browser that opens has acess to the internet. when I type another url in the adress bar, it goes there.

A friend of mine said freewebs may have some kind of firewall thats restricting this sort of access. Which is why I was wondering if there was another good place to save my applets.

mikau16a at 2007-7-12 10:03:59 > top of Java-index,Java Essentials,New To Java...
# 8

Is the web page that has the <applet> tag on it on the same server as the applets?

It's possible that freewebs blocks applets. You should ask them. But if they did, you'd probably still be able to connect to the server; it's just that the applet you get back would be corrupted or zero length or have a bad status code (most likely, for reasons I don't want to go into). You probably wouldn't get a stack trace message saying that it couldn't connect at all. On the other hand, maybe the message is just obscure.

Were you able to read the web server logs, to see if the applet was referenced and if so what the response was? Was there a corresponding message in the error log.

Personally, I wouldn't use a web provider if they didn't let me have access to the logs.

I have a couple web sites at verio.net and applets aren't a problem, although this is not an endorsement. I'll bet applets are OK at most places.

paulcwa at 2007-7-12 10:03:59 > top of Java-index,Java Essentials,New To Java...
# 9

> java.lang.ClassNotFoundException: http:..www.freewebs.com.mikau16.JavaShapeArray4.class

This is a bit suspicious-looking, don't you think? Why did those slashes get changed to dots?

It's because your CODE attribute is supposed to contain a class name. You gave it a URL instead.

DrClapa at 2007-7-12 10:03:59 > top of Java-index,Java Essentials,New To Java...
# 10
I'm supposed to give it just a classname?Okay, but how will the program know where to look if i don't provide the full url?
mikau16a at 2007-7-12 10:03:59 > top of Java-index,Java Essentials,New To Java...
# 11

i should probably add that the html file is not saved on the same server as the applet.

The reason I have the applet on the freewebs account is so that I can access it with an html document from anywhere. Like how some sites give you a strip of code that allows you to put an applet on your website, or a myspace page or something similar to that.

so if i call the applet from anywher just by its name, the page will not know where to find it. but prodividing the url screws things up. So how can I fix this?

mikau16a at 2007-7-12 10:03:59 > top of Java-index,Java Essentials,New To Java...
# 12

I believe you can use the CODEBASE attribute on the APPLET tag to tell it where to look for code. Then use the CODE attribute to tell it the classname to use.

So if the class is called Foo, and it's in the "bar" package, and you keep all your code in the "baz" directory on www.buzz.com, then I thing you can do this:

<applet code="bar.Foo" codebase="http://www.buzz.com/baz/"></applet>

But please check the docs to make sure.

And also check with the web site to confirm that you can read logs. IMHO, trying to debug web stuff online without checking logs first is almost pointless.

paulcwa at 2007-7-12 10:03:59 > top of Java-index,Java Essentials,New To Java...