NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
October 22, 2017, 01:27:50 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Wisdom is to teach our students how to teach themselves. ...Wisdom
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: How to write the applet code for embedding in other websites where jar is upload  (Read 6934 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
on: March 12, 2010, 08:39:04 am » posted from:SINGAPORE,SINGAPORE,SINGAPORE

Hi Prof,
How to write the applet code for embedding in other websites where jar is uploaded?

for example,
http://lookang.wikispaces.com/

i uploaded the jar file to wikipspaces
http://lookang.wikispaces.com/file/detail/ejs_users_sgeducation_lookang_Momentum1D2010web.jar

the page currently has 2 embed codes

the first one works well, because the codes is modified to read from  http://www.phy.ntnu.edu.tw/ntnujava/ejsuser/14019/ejs_Momentum1D2010web.jar

 
Code:

but now the second embed code i want to experiment and draw the applet codes from http://lookang.wikispaces.com/file/detail/ejs_users_sgeducation_lookang_Momentum1D2010web.jar

i tried
Code:

but i got an error message
Quote
APPLET tag missing CODE parameter.
load: class users.sgeducation.lookang.Momentum1D2010web_pkg.Momentum1D2010webApplet.class not found.
java.lang.ClassNotFoundException: users.sgeducation.lookang.Momentum1D2010web_pkg.Momentum1D2010webApplet.class
   at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
   at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
   at sun.plugin2.applet.Plugin2ManagerAppletExecutionRunnable.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://lookang.wikispaces.com/ejsuser/14019/users/sgeducation/lookang/Momentum1D2010web_pkg/Momentum1D2010webApplet/class.class
   at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
   at sun.plugin2.applet.Applet2ClassLoader.access000(Unknown Source)
   at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   ... 7 more
Exception: java.lang.ClassNotFoundException: users.sgeducation.lookang.Momentum1D2010web_pkg.Momentum1D2010webApplet.class

I thought everything is inside the jar, how come cannot find class users.sgeducation.lookang.Momentum1D2010web_pkg.Momentum1D2010webApplet.class ?

what should the embed codes be for different url address of the jar?
thanks!
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #1 on: March 12, 2010, 10:07:44 am » posted from:Taipei,T\'ai-pei,Taiwan

The jar fie is available from http://lookang.wikispaces.com/file/detail/ejs_users_sgeducation_lookang_Momentum1D2010web.jar
However, the above URL is a web page content which show the download link.


You can find out the actual URL from the above web page:
http://lookang.wikispaces.com/file/view/ejs_users_sgeducation_lookang_Momentum1D2010web.jar/126986537/ejs_users_sgeducation_lookang_Momentum1D2010web.jar
Separate the above URL into path and file part
path=http://lookang.wikispaces.com/file/view/ejs_users_sgeducation_lookang_Momentum1D2010web.jar/126986537/
file=ejs_users_sgeducation_lookang_Momentum1D2010web.jar
Then, the code base and archive tags for applet code should be
Code:
codebase="path" archive="file"
The name and id tags should be unique at the same page (if you have more than one applets , each name and id should be unique).
So the complete applet code to show the applet might be
Code:
<applet archive="ejs_users_sgeducation_lookang_Momentum1D2010web.jar" code="users.sgeducation.lookang.Momentum1D2010web_pkg.Momentum1D2010webApplet.class" codebase="http://lookang.wikispaces.com/file/view/ejs_users_sgeducation_lookang_Momentum1D2010web.jar/126986537/" height="600" id="Momentum1D2010web3151" name="Momentum1D2010web3151" width="900"></applet>

The following is the result of the above code



Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #2 on: March 12, 2010, 11:59:56 am » posted from:SINGAPORE,SINGAPORE,SINGAPORE

amazing! You solve the problem. Thanks

I figure you

from browser click on View and Page Source
CTRL-F to find the keyword or browse and CTRL-C the the file and path as you mentioned above.

interesting. I didn't know the the file right-click copy link is different from the actual path and file.

i now can follow your example code and progress on.

Thanks! 
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #3 on: March 12, 2010, 12:33:04 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

hmmmmm...i thought i understood the codes but when i tried it on my own forum http://66.7.205.91/~lookangc/index.php?topic=1009.0

from


I thought the file name is correct
applet archive="ejs_users_sgeducation_lookang_Momentum1D2010web.jar"

I thought the path should be this
codebase="http://66.7.205.91/~lookangc/public_html/attachments/"

i tried many different path but seems all wrong
codebase="http://66.7.205.91/~lookangc/home/lookangc/public_html/attachments/"
codebase="http://66.7.205.91/~lookangc/attachments/"
etc it does not seem to work.


the actual attachment is here http://66.7.205.91/~lookangc/index.php?action=dlattach;topic=1009.0;attach=1107

the error message is
Java Plug-in 1.6.0_18
Using JRE version 1.6.0_18-b07 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\temp
----------------------------------------------------
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
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
----------------------------------------------------


load: class users.sgeducation.lookang.Momentum1D2010web_pkg.Momentum1D2010webApplet.class not found.
java.lang.ClassNotFoundException: users.sgeducation.lookang.Momentum1D2010web_pkg.Momentum1D2010webApplet.class
   at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
   at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
   at sun.plugin2.applet.Plugin2ManagerAppletExecutionRunnable.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://66.7.205.91/~lookangc/public_html/attachments/users/sgeducation/lookang/Momentum1D2010web_pkg/Momentum1D2010webApplet/class.class
   at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
   at sun.plugin2.applet.Applet2ClassLoader.access000(Unknown Source)
   at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   ... 7 more
Exception: java.lang.ClassNotFoundException: users.sgeducation.lookang.Momentum1D2010web_pkg.Momentum1D2010webApplet.class

How do i solve this?
Thanks!
« Last Edit: March 12, 2010, 12:44:27 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #4 on: March 12, 2010, 03:08:33 pm » posted from:Taipei,T\'ai-pei,Taiwan

Quote

1. There is no way to separate the filename and the file path, because the above URL did not contain file name.
You can use archive="the actual attachment is here http://66.7.205.91/~lookangc/index.php?action=dlattach;topic=1009.0;attach=1107" and without codebase in the applet tag to solve the problem.
However, the above URL did not link to the jar file. Because it will be re-direct to login page.
May be you will not see the login page , because browser did the login trick for you.
However, it you logout your forum and try to aceess the above URL again, it will be re-direct to login page.

The same things happened when java/other users try to access the above URL.
That is the reason why java was not able to find the required jar file with the above URL(java should not be able to acces your server because java program can not login)
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #5 on: March 13, 2010, 08:54:10 am » posted from:Singapore,,Singapore

http://66.7.205.91/~lookangc/index.php?action=dlattach;topic=1009.0;attach=1107

based on the discussions
i tried


i think it work for your forum , am currently login to my forum.
I going to try on my forum. 
Horray!!!!!! it works!!! cool thanks!
U are a great sage!
« Last Edit: March 13, 2010, 08:58:42 am by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #6 on: March 13, 2010, 09:32:01 am » posted from:Taipei,T\'ai-pei,Taiwan

It will only work for you when you login to your server first.
However, it would not work for other users (in general).
Because other user did not know that they need to login to your server before there access the above page.

I will be re-direct to a login page when I try to access http://66.7.205.91/~lookangc/index.php?action=dlattach;topic=1009.0;attach=1107
You need to provide an URL which is open to public (without login requirement).
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #7 on: March 13, 2010, 11:55:04 am » posted from:Singapore,,Singapore

It will only work for you when you login to your server first.
However, it would not work for other users (in general).
Because other user did not know that they need to login to your server before there access the above page.

I will be re-direct to a login page when I try to access http://66.7.205.91/~lookangc/index.php?action=dlattach;topic=1009.0;attach=1107
You need to provide an URL which is open to public (without login requirement).

I used a trick, i login as admin, goto members permission, modify guest permission, check on the box
Attachments
View attachments set to true by selecting the checkbox, Done!!, like a normal applet website now.

i think i will    stick to SMF forum for the time being, i will just post here for community outreach and on my own SMF as a alternate backup!

thanks for your excellent help!
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #8 on: March 13, 2010, 07:43:43 pm » posted from:Taipei,T\'ai-pei,Taiwan

Yes. You got it. You need to make sure anonymous user can access the correct jar file from the provided URL.
Logged
Pages: [1]   Go Up
  Print  
Wisdom is to teach our students how to teach themselves. ...Wisdom
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Can you send me the 2d collision applet source code?
Comment about this web site!
4 18890 Last post August 13, 2010, 11:38:09 am
by icetreat
The source code for the double slit applet?
Comment about this web site!
fkj 0 16036 Last post October 28, 2004, 03:03:19 pm
by fkj
Could you send me the code of your applet?
Information and Download
barffour 3 12852 Last post April 10, 2015, 02:20:32 pm
by siamon
I was inspired to write this down and i wanted to share with everyone :)
Comment about this web site!
lookang 3 6317 Last post August 02, 2011, 06:29:11 am
by egabev
World Adoption & Usage using NTNUJAVA Forum applets by allowing easy embedding?
Questions related to EJS
lookang 8 7557 Last post August 26, 2011, 08:38:37 pm
by ahmedelshfie
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.075 seconds with 23 queries.since 2011/06/15