Include java applet in ruby on rails web pages

Hi,
I am new to Ruby on Rails world, and would like to combine the ease
of RoR web programming with rich graphics and applications from java
applets.
Wonder if anyone have tried that before?
I am having difficulty to use java applet in my .rhtml view files. I
ran
a simple test case (files given below) and got error that applet could
not
be started (notinited) or loading java applet failed. When I ran the
web page directly (changing Hello.rhtml to Hello.html), it ran fine.
I also noticed that in the log file from rails the applet was loaded
twice.
Like to find out how to include an applet in a ,rhtml file. Please
help.
Sincerely,
HT Yeh

applet_controller

class AppletController < ApplicationController
def Hello
end
end

Hello.rhtml

Hello.java (to compile into Hello.class)

import java.awt.;
import javax.swing.
;

public class Hello extends JApplet
{
public void init()
{
Container contentPane = getContentPane();
JLabel label = new JLabel(“Hello”, SwingConstants.CENTER);
contentPane.add(label);
}
}

Have you tried using the tag? is really meant for IE
only,
otherwise you do have the tag. Also, is the class file in the
right
location for Rails to find it? Though I don’t know where the best place
to
put it is, whether in public/ or next to the rhtml.

Jason

On Thu, Sep 21, 2006 at 01:16:19PM -0400, Jason R. wrote:

Have you tried using the tag? is really meant for IE only,

No, “object” is made for standards compliance. Please read up on html
before trying to explain it to others…

otherwise you do have the tag. Also, is the class file in the right
location for Rails to find it? Though I don’t know where the best place to
put it is, whether in public/ or next to the rhtml.

In public. Unless it’s a template of some sort, it doesn’t belong in
app/views.


You might want to look around on the w3.org site for information on the
object tag. I believe that for modern html, you need only do something
like this:


You don’t have java :frowning:

With the text in there being the “alternative” text. I use very similar
syntax for embedding a couple of flash elements into a site that I’ve
recently completed and it works great. No “applet” or “embed” tags, and
it’s much cleaner syntax because of it.

Michael

Michael Darrin Chaney
[email protected]
http://www.michaelchaney.com/

+1 for Jason

You need to export the classpath and javahome before running ruby
script/server so that it can find the class…(I think)

So Sun is completely wrong about applet deploying?

Man the w3 site is frustrating to navigate. Finally found:

http://www.w3.org/TR/html4/struct/objects.html#edef-OBJECT
http://www.w3.org/TR/html4/struct/objects.html#edef-APPLET

So the w3 standard is as says, but that means what? We all know that
browsers are not fully W3 standardized, especially IE, so I’ll ask
again:

Have you tried other tags besides object?

And maybe try informing instead of berating next time, it’s very
unbecoming.

Jason

here’s my example crap (just threw it together out of interest… but
in case you need it)
-----------------------------views/test/index.rhtml------------------------------------------------------

-----------------------------command line
crap----------------------------------------------------------

Note, I just threw your Hello.java in the jdk bin directory and

compiled it from there…

C:\rails\javatest>set CLASSPATH=“C:\Program Files\Java\jdk1.5.0_07\bin”
C:\rails\javatest>set JAVAHOME=“C:\Program Files\Java\jdk1.5.0_07\bin”
C:\rails\javatest>ruby script/server

good luck…

On Thu, Sep 21, 2006 at 04:26:58PM -0400, Jason R. wrote:

So Sun is completely wrong about applet deploying?

http://java.sun.com/docs/books/tutorial/deployment/applet/deployindex.html

Apparently. is the future.

Man the w3 site is frustrating to navigate. Finally found:

Objects, Images, and Applets in HTML documents
Objects, Images, and Applets in HTML documents

So the w3 standard is as says, but that means what? We all know that
browsers are not fully W3 standardized, especially IE,

Right. Ironically, in this case, though, you claim that IE is the
browser where “object” works. Think about it.

so I’ll ask again:

Have you tried other tags besides object?

And maybe try informing instead of berating next time, it’s very unbecoming.

Let’s deconstruct this briefly. Some guy asks about using the
tag, which is correct. You come in and tell him that he’s wrong to use
it, that it’s an IEism:

On Thu, Sep 21, 2006 at 01:16:19PM -0400, Jason R. wrote:

Have you tried using the tag? is really meant for IE
only,

I’m not berating you. Just please be careful as bad advice tends to end
up in Google.

Michael

Michael Darrin Chaney
[email protected]
http://www.michaelchaney.com/

Bad advice? Who’s giving bad advice? Are you trying to say that I’m
mis-leading the OP? As for in IE, what is there to think about?
I
read from Sun’s website that is for IE. Thus I recommend using
or . If you actually cared about preventing “bad advice”
you
wouldn’t be launching into an egotistical “you’re wrong, I’m right, and
you
should know this already” campaign.

As the OP has yet to respond to the topic, why don’t we just wait for
it, if
it comes and continue to help when and if needed.

Jason