I would like to create and work a signed applet from an applet that I wrote. The applet itself uses a library (owlapi) that has to have the correct write rights in order to save the changes made to the owl repository.
In order to do this I should use a .policy file or signed applets. To make signed applets I followed this manual. I follow that manual on the letter, and yet it doesn't work. I get to the point where I have a signed applet and include it in the html like this:
<applet code="owlapi.LoadOntology.class" archive="owlapi/SignedLoadOntology.jar" height=100 width=1000 MAYSCRIPT>
<param NAME="archive" VALUE='owlapi/Signedowlapi-src.jar, owlapi/Signedowlapi-bin.jar'>
</applet>
When I am testing that applet with the appletviewer (which is recommended in that manual), I get the error
I thought I could solve that by manually compile the code with that library and then create a jar with all those .class files, but that didn't help:
javac -cp owlapi-src.jar:owlapic-bin.jar LoadOntology.java
jar cvf LoadOntology *.class
Does anybody know how to create such a signed applet that uses a some other jar-files?
*update: * after reading this thread, I found out that the owlapi-src and owlapi-bin jars had to be included to the applet in the html an should be signed too. I changed the code to my current testing code, but that still didn't work, since I now have again the
java.lang.SecurityException: Unable to create temporary file
which means that the code from the used owlapi library isn't found.
You probably need not include the -src jar, as I'd expect it to contain the java sources.
I do think you need to provide both your own signed jar and the signed library jar in one and the same applet parameter, as follows:
<applet code="owlapi.LoadOntology.class" height=100 width=1000 MAYSCRIPT>
<param NAME="archive"
VALUE='owlapi/SignedLoadOntology.jar, owlapi/Signedowlapi-bin.jar'>
</applet>
Related
I have an html file with applet code like
<applet code="myapplet.class" archive="http://localhost:8080/myapplets.jar"width="350" height="350"></applet>
The applet loads fine if the html file is local to the machine but if that html file is on shared drive (windows) and if html file opened ( so that the address in the address bar is
\X.X.X.X\testhtml\myapplethost.html ) then
While applet is trying to load , this exception is thrown
java.lang.SecurityException: Permission denied: http://localhost:8080/myapplets.jar
I have added both the
http://localhost:8080 and file:\\X.X.X.X\testhtml
to the exception list. Have lowered the security to the lowest possible (i.e Medium) in java control panel (JRE 1.7 upate 67) but this applet keeps getting blocked. Is there any settign that can help here to allow the access to applet from the shared location? Thanks
The archive parameter of the applet can only reference archives (e.g. jar files) from the same source the applet was started. Here is the quote from the official documentation:
For security reasons, the applet's class loader can read only from the same codebase from which the applet was started. This means that archives in archiveList must be in the same directory as, or in a subdirectory of, the codebase.
If you load the HTML page from a shared drive, the archive attribute of the applet tag in the HTML file should not point to http://localhost:8080/myapplets.jar. Most likely this is just a mistake (you forgot to change it or you forgot to use relative URL).
Just change the archive attribute to a relative URL and it will work. Something like this:
<applet code="myapplet.class" archive="myapplets.jar" width="350" height="350">
</applet>
Absoulte URLs are always a bad idea and this is especially true for applet archives.
Used shared drive path (like Z: instead of \server ) and it works.
I want to embed a java applet (stored in a git repository) in the accompanying github-pages page. Is this possible?
Yes.
Although GitHub pages can be generated through a simple markdown interface, any files in your branch will be served as part of your gh-pages-site.
This means you can host client side scripts like Java-Applets or JS on your GitHub Pages site.
To host a java applet:
Create a jar file for your Applet.
Place the .jar file into the root of your gh-pages branch.
Embed the applet in one of your html pages using your prefered method like this, or maybe this:
*Assuming foo.jar and Bar.class are your file and applet-class*
<embed
id="SomeName"
type="application/x-java-applet;version=1.6"
width="999" height="999"
archive="foo.jar"
code="Bar.class"
pluginspage="http://java.com/download/"
myParam="YourParams" />
Commit/Push the changes and wait (sometimes gh-pages are not updated immediately).
I've built an applet (from JApplet) that consumes several other jar files. I've signed my jar that contains the main class and included all of the jars I need (I think). However, no matter what I try, I consistently get "java.lang.ClassNotFoundException: newposting" where 'newposting' is the main class within my signed jar. I'm using the following html for this:
<p><applet code="newposting"
archive="HartfordRowingNewPosting.jar,
javax.mail.jar,
jcalendar-1.4.jar,
junit-4.6.jar,
jgoodies-common-1.2.0.jar,
jgoodies-looks-2.4.1.jar,
mysql-connector-java-5.1.25-bin.jar"
width="500" height="850">
<param name="permissions" value="sandbox" />
<param name="codebase" value="HartfordRowingNewPosting.jar" />
</applet></p>
The jars and html are all located in the same folder on the server. I've tried several combinations of path specifications. I've also tried using jnlp but get the same error. I've been frustrated with this on and off for the last month or so. Can someone shed some light on this?
The fact the ClassNotFoundException is thrown when loading your main class means that either your class cannot be read from jar or your jar cannot be found.
I hope that your verified that your clas is indeed in jar. If not try it. Just to be sure try to use unsigned jar and see that you have exactly the same error.
If so you still have 2 possibilities.
Are you sure that your class is indeed called newposting? Lowercase? In default package? Note: this must be fully qualified class name.
Next, test that your jar is indeed available for browser. To do so just copy and paste the jar name to browser prepending it with your URL. For example if HTML is available under http://myhost/myapp/mypage.html try URL http://myhost/myapp/HartfordRowingNewPosting.jar.
BTW what does parameter codebase mean? Is it your application level parameter? I am not sure but make sure that this does not confuse browser with attribute codebase supported by tag applet. This attribute is typically .: <applet codebase="." that means "download jars from current directory". This is the same as to say java -cp . when running java from command line.
BTW, do you know that applets were almost obsolete about 10 years ago? Moreover as far as I can see you included MySql JDBC driver into your class path. You should understand that this will not work in most cases because typically there is a firewall that does not allow JDBC protocol between clients and server.
This topic has been covered in one form or another but none of the other threads have been able to help. My issue is very similar to this post, I am making a JUNG graph with added functionality, but none of the solutions helped:
JApplet fails to run in HTML page
I had a Java application that I converted to a JApplet. The JApplet works fine in the applet viewer in Eclipse but will not work when I try to open it in a webpage (I have tried IE, FireFox, and Chrome). I have my HTML page and archive folder both in the same directory. When I load the HTML page it just brings up nothing.
Here is my html code:
<html>
<title>Applet</title>
<head>
</head>
<body>
<applet code="prerna.blueprint.main.BPTester.class"
archive="applet1.jar"
width="800" height="800">
</applet>
</body>
</html>
When I try to have code="BPTester.class" it gives java.lang.ClassNotFoundException: BPTester.class but when I use code="prerna.blueprint.main.BPTester.class" it gives me no errors just nothing happens. (prerna/blueprint/main/BPTester.class is the file path in my src folder). I exported my Java project as a runnable jar file, is this correct? I created a simple JApplet that worked fine when I did all the same steps but it won't work for BPTester.class.
If I need to post my BPTester.class code I can.
I don't understand why I can't view the JApplet in a webpage, any help is greatly appreciated.
What ended up working for me was adding every single jar I used in the japplet to the HTML archive tag then had to sign every jar. I then had an issue with accessing my database within the applet1.jar so I just put an absolute path for its location.
java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
The applet needs to be digitally signed (by you) and trusted (by the end user, when prompted) before it can obtain such information. Given this applet is being deployed using a traditional applet element (i.e. not using web start), all jars need to be signed.
You need to sign every jar. You can sign all the jars with the jarsigner utility. Example:
jarsigner.exe "nameofthejar.jar" "alias"
Remove .class from the end. You either use a file path with slashes and .class at the end or you only use periods and no .class at the end.
Try turning on tracing in the java control panel. It will then produce a log file in the following path that may help: %USERPROFILE%\AppData\LocalLow\sun\java\Deployment\log
Can anyone help me out. I've written a program that controls the heating system in an imaginery house, an applet actually. it runs fine in netbeans but i cant get it to run as an applet in a browser, can anyone help me out please, I linked to a zip folder of all my code...
http://dl.dropbox.com/u/47863/Heating%20System.zip
http://alcaeos.com/applet/classes/MyHomeHeating.class -> 404.
Or to put that another way.
The applet element is telling the JRE to look for the class at the URL mentioned above.
The class is not at that location. (Neither is it in the same directory as the HTML.)
Where is the class file?
BTW: Typical bloody Netbeans generated code (/HTML). When what it generates is not invalid, it is redundant.
code="MyHomeHeating.class" The code attribute should not include .class.
<HR WIDTH="100%"> An HR element normally spans the entire width of the page.
You need to compile your applet into .class files (not .java files like you have in the ZIP; those are source code) and embed it into an HTML page. You can use the tag in HTML to do these; read more here: http://www.echoecho.com/applets01.htm