• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Where should I put the applet?

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Graph.java which extends JApplet, and import a java_c.Caller.java which will call a dll in my pc.
Make it clear:
Graph.java extends JApplet,and calls Caller.java
Caller.java calls a dll in my pc.

I want to put them in the Tomcat\webapps\myapp, how shoul I do?
Thanks!!!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'd put the class files along with the HTML file that contains the applet tag into ...\myapp. I'm not sure where the DLL needs to go on a Windows machine, probably into a directory that's part of PATH.

In any case, you need to allow the applet to use native libraries. The two methods for doing that are described here.
 
Kidd He
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
You'd put the class files along with the HTML file that contains the applet tag into ...\myapp. I'm not sure where the DLL needs to go on a Windows machine, probably into a directory that's part of PATH.

In any case, you need to allow the applet to use native libraries. The two methods for doing that are described here.



Thanks!!But I think the dll file is on my pc, so is in the host, why should I sign the applet.In fact my applet can run on the appletviewer and cannot on the ie or firefox?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because applets have security restrictions in what they are allowed to do. Accessing native libraries is one of the things they can't do. Appletviewer does not generally enforce these restrictions, but browsers do.
 
Kidd He
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
Because applets have security restrictions in what they are allowed to do. Accessing native libraries is one of the things they can't do. Appletviewer does not generally enforce these restrictions, but browsers do.



Thank for your answer!!!
 
Kidd He
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another question:
I have resolve the problem dll.I make a jar file including the applet、the Caller(call the dll)and 3 images.The applet should read the images,one is the background, others are button's icons.But why in the browser,the images can't be read?
My step:
1、Make the applet、Caller.java(it's in the java_c package),the images together into applet.jar.
2、Ues the commands:
keytool -genkey -keystore kidd.store -alias kidd
keytool -export -keystore kidd.store -alias kidd -file kiddr.cert
jarsigner -keystore kidd.store applet.jar kidd
3、Create a applet.policy file,with the following content:
keystore "file:E: /javacode/kidd.store", "JKS";
  grant signedBy "kidd"
  { permission java.io.FilePermission }
4、add a line in the ${java.home}/jre/lib/security/java.security:
policy.url.3=file:E: /javacode/applet.policy
Now I can run applet in the browser,but it still can't show the 3 images,why?


One more question:
I want to move the applet.jar in the ${Tomcat.home}/webapps/myapp, I think it mustnot under the ../myapp/WEB-INF, because the applet will be downloaded.But the applet.jar has included the java_c package(Caller.java in it),I want to make the java_c package move from applet.jar to the ../WEB-INF/classes. How can I do?Can the applet in the jar call a class in the WEB-INF/classes?How should I change my code?

Really Thanks!!!
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the images are inside of the jar file, then the browser can't access them - only the applet can read them. If you want to use them in HTML as well, then you need to keep them outside of the jar file.

Applet classes can't be anywhere inside of WEB-INF, because that directory is not publicly accessible.
 
Kidd He
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
If the images are inside of the jar file, then the browser can't access them - only the applet can read them. If you want to use them in HTML as well, then you need to keep them outside of the jar file.

Applet classes can't be anywhere inside of WEB-INF, because that directory is not publicly accessible.



Yes, thanks for your reply.But the first question is "I put the images in the jar, I want them to be read by applet and be showed. One is applet' backgroud ,others are button's Icon. So I think in the browser ,them should be read by applet not html. But in fact, them didn't appear, on the other hand them appeared in the AppletViewer. So I'm puzzled "
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see - by "in the browser" I thought you meant as opposed to "in the applet". But you meant as opposed to "in appletviewer".

What code are you using to access the images? Are there any exceptions?
 
Kidd He
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
I see - by "in the browser" I thought you meant as opposed to "in the applet". But you meant as opposed to "in appletviewer".

What code are you using to access the images? Are there any exceptions?



I'll make my questions clearer next time.
The code to read the backgroud image is


The code of the buttons is:


When the applet is running in FireFox, the console print the exception is:

There aren't any exceptions of the buttons' images. But all the 3 images didn't appear.Please tell me why?Thanks!
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

File f = new File("main.jpg");
img = ImageIO.read(f);



This only works for images in the local file system, not for images that are in the applet jar file, or in the same web directory. Resources in the jar file can be accessed as described here. Files in the web directory can be accessed through HTTP with the HttpUrlConnection class.

As to the image icons, are the images on the top level of the jar file, i.e. not in a directory?
[ January 10, 2007: Message edited by: Ulf Dittmer ]
 
Kidd He
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks !
Following your reply, I made the backgroud image shown in the Firefox.

The two Icons are on the top level of the jar file.What can I do with them?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is some code that pulls an image out of a jar file for use as a label:


[ January 10, 2007: Message edited by: Ulf Dittmer ]
 
Kidd He
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You are a nice man!!!Really really thank you!!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic