ht_yeh-/E1597aS9LQAvxtiuMwx3w@public.gmane.org
2006-Sep-21 14:39 UTC
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 <html> <body> <object codetype="application/java" classid="java:Hello.class" width="300" height="300" > </object> </body> </html> 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); } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Have you tried using the <applet> tag? <object> is really meant for IE only, otherwise you do have the <embed> 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 9/21/06, ht_yeh-/E1597aS9LQAvxtiuMwx3w@public.gmane.org <ht_yeh-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> > > 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 > > <html> > <body> > <object codetype="application/java" classid="java:Hello.class" > width="300" height="300" > > </object> > </body> > </html> > > > 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); > } > } > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On Thu, Sep 21, 2006 at 01:16:19PM -0400, Jason Roelofs wrote:> Have you tried using the <applet> tag? <object> 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 <embed> 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.> > <object codetype="application/java" classid="java:Hello.class" > > width="300" height="300" > > > </object>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: <object type="application/x-java-applet" src="Hello.class" width="300" height="300"> You don''t have java :( </object> 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 mdchaney-c1nKWHh82D8TjS1aD1bK6AC/G2K4zDHf@public.gmane.org http://www.michaelchaney.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
So Sun is completely wrong about applet deploying? http://java.sun.com/docs/books/tutorial/deployment/applet/deployindex.html 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 On 9/21/06, Michael Chaney <mdchaney-c1nKWHh82D8TjS1aD1bK6AC/G2K4zDHf@public.gmane.org> wrote:> > > On Thu, Sep 21, 2006 at 01:16:19PM -0400, Jason Roelofs wrote: > > Have you tried using the <applet> tag? <object> 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 <embed> 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. > > > > <object codetype="application/java" classid="java:Hello.class" > > > width="300" height="300" > > > > </object> > > 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: > > <object type="application/x-java-applet" src="Hello.class" width="300" > height="300"> > You don''t have java :( > </object> > > 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 > mdchaney-c1nKWHh82D8TjS1aD1bK6AC/G2K4zDHf@public.gmane.org > http://www.michaelchaney.com/ > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
+1 for Jason On 9/21/06, Jason Roelofs <jameskilton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > So Sun is completely wrong about applet deploying? > > http://java.sun.com/docs/books/tutorial/deployment/applet/deployindex.html > > 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 > > On 9/21/06, Michael Chaney < mdchaney-c1nKWHh82D8TjS1aD1bK6AC/G2K4zDHf@public.gmane.org> wrote: > > > > > > On Thu, Sep 21, 2006 at 01:16:19PM -0400, Jason Roelofs wrote: > > > Have you tried using the <applet> tag? <object> 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 <embed> 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. > > > > > > <object codetype="application/java" classid="java:Hello.class" > > > > width="300" height="300" > > > > > </object> > > > > 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: > > > > <object type="application/x-java-applet" src="Hello.class" width="300" > > height="300"> > > You don''t have java :( > > </object> > > > > 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 > > mdchaney-c1nKWHh82D8TjS1aD1bK6AC/G2K4zDHf@public.gmane.org > > http://www.michaelchaney.com/ > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
You need to export the classpath and javahome before running ruby script/server so that it can find the class...(I think) On 9/21/06, Jamie Quint <jsquintz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> +1 for Jason > > > On 9/21/06, Jason Roelofs <jameskilton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > So Sun is completely wrong about applet deploying? > > > > > http://java.sun.com/docs/books/tutorial/deployment/applet/deployindex.html > > > > 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 > > > > > > > > On 9/21/06, Michael Chaney < mdchaney-c1nKWHh82D8TjS1aD1bK6AC/G2K4zDHf@public.gmane.org> wrote: > > > > > > On Thu, Sep 21, 2006 at 01:16:19PM -0400, Jason Roelofs wrote: > > > > Have you tried using the <applet> tag? <object> 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 <embed> 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. > > > > > > > > <object codetype="application/java" classid="java:Hello.class" > > > > > width="300" height="300" > > > > > > </object> > > > > > > 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: > > > > > > <object type="application/x-java-applet" > src="Hello.class" width="300" height="300"> > > > You don''t have java :( > > > </object> > > > > > > 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 > > > mdchaney-c1nKWHh82D8TjS1aD1bK6AC/G2K4zDHf@public.gmane.org > > > http://www.michaelchaney.com/ > > > > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
here''s my example crap (just threw it together out of interest.. but in case you need it) -----------------------------views/test/index.rhtml------------------------------------------------------ <applet width=300 height=300 code="Hello.class"> </applet> -----------------------------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 9/21/06, x1 <caldridge-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You need to export the classpath and javahome before running ruby > script/server so that it can find the class...(I think) > > On 9/21/06, Jamie Quint <jsquintz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > +1 for Jason > > > > > > On 9/21/06, Jason Roelofs <jameskilton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > So Sun is completely wrong about applet deploying? > > > > > > > > http://java.sun.com/docs/books/tutorial/deployment/applet/deployindex.html > > > > > > 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 > > > > > > > > > > > > On 9/21/06, Michael Chaney < mdchaney-c1nKWHh82D8TjS1aD1bK6AC/G2K4zDHf@public.gmane.org> wrote: > > > > > > > > On Thu, Sep 21, 2006 at 01:16:19PM -0400, Jason Roelofs wrote: > > > > > Have you tried using the <applet> tag? <object> 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 <embed> 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. > > > > > > > > > > <object codetype="application/java" classid="java:Hello.class" > > > > > > width="300" height="300" > > > > > > > </object> > > > > > > > > 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: > > > > > > > > <object type="application/x-java-applet" > > src="Hello.class" width="300" height="300"> > > > > You don''t have java :( > > > > </object> > > > > > > > > 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 > > > > mdchaney-c1nKWHh82D8TjS1aD1bK6AC/G2K4zDHf@public.gmane.org > > > > http://www.michaelchaney.com/ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On Thu, Sep 21, 2006 at 04:26:58PM -0400, Jason Roelofs wrote:> So Sun is completely wrong about applet deploying? > > http://java.sun.com/docs/books/tutorial/deployment/applet/deployindex.htmlApparently. <object> is the future.> 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,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 <object> 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 Roelofs wrote: > > > Have you tried using the <applet> tag? <object> 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 mdchaney-c1nKWHh82D8TjS1aD1bK6AC/G2K4zDHf@public.gmane.org http://www.michaelchaney.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Bad advice? Who''s giving bad advice? Are you trying to say that I''m mis-leading the OP? As for <object> in IE, what is there to think about? I read from Sun''s website that <object> is for IE. Thus I recommend using <applet> or <embed>. 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 On 9/21/06, Michael Chaney <mdchaney-c1nKWHh82D8TjS1aD1bK6AC/G2K4zDHf@public.gmane.org> wrote:> > > On Thu, Sep 21, 2006 at 04:26:58PM -0400, Jason Roelofs wrote: > > So Sun is completely wrong about applet deploying? > > > > > http://java.sun.com/docs/books/tutorial/deployment/applet/deployindex.html > > Apparently. <object> is the future. > > > 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, > > 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 <object> > 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 Roelofs wrote: > > > > Have you tried using the <applet> tag? <object> 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 > mdchaney-c1nKWHh82D8TjS1aD1bK6AC/G2K4zDHf@public.gmane.org > http://www.michaelchaney.com/ > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---