Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > having trouble using signed java applet

Reply
Thread Tools

having trouble using signed java applet

 
 
Darren
Guest
Posts: n/a
 
      09-20-2005
Hi i wrote an applet recently and posted a request here for help in allowing
it to open a socket. I got some excellent info on creating self signed jar
files that allow me access to functions normally prohibited to java applets.
Now i've follwoed the instructions but now my heml code has trouble
accessing the jar file.

here's the steps i took in creating the self signed jar file.
firstly i created the certificate
c:\j2sdk1.4.2_06\bin\keytool -genkey -keyalg rsa -alias dazkey
c:\j2sdk1.4.2_06\bin\keytool -export -alias dazkey -file dazsuncert.crt
then i created the jar
c:\j2sdk1.4.2_06\bin\jar cvf c:\applets\Helloserver.jar
c:\applets\Helloserver.class
then signed and verified it
c:\j2sdk1.4.2_06\bin\jarsigner c:\applets\Helloserver.jar dazkey
c:\j2sdk1.4.2_06\bin\jarsigner -verify -verbose -certs
c:\applets\Helloserver.jar

to test it i put the jar file and html file on there own on my website

Helloserver.htm
Helloserver.jar

the content of the html file are as follows
<HTML>
<HEAD>
</HEAD>
<BODY>
<CENTER>
<APPLET
codebase = "."
archive = "Helloserver.jar"
code = "Helloserver.class"
width = "500"
height = "300"
>

</APPLET>
</CENTER>
</BODY>
</HTML>

The java consol stated the following
Java Plug-in 1.5.0_04
Using JRE version 1.5.0_04 Java HotSpot(TM) Client VM
User home directory = C:\WINDOWS


load: class Helloserver.class not found.
java.lang.ClassNotFoundException: Helloserver.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed.
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more
Exception in thread "Thread-4" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Un known Source)
at sun.plugin.AppletViewer.showAppletException(Unknow n Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Un known Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "thread applet-Helloserver.class"
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Un known Source)
at sun.plugin.AppletViewer.showAppletException(Unknow n Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

now when i put the class file instead of the jar and removed the jar file
and the archive tag from the html file the class loads ok but again i get
the security problems.

Help



 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      09-20-2005
On Tue, 20 Sep 2005 17:59:03 GMT, "Darren" <> wrote
or quoted :

> archive = "Helloserver.jar"
> code = "Helloserver.class"


You don't post a class without a package. That is only for
experimenting. I suspect signing presumes packages.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      09-20-2005
On Tue, 20 Sep 2005 17:59:03 GMT, "Darren" <> wrote
or quoted :

> codebase = "."


that does not do anything. Just leave it out.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      09-20-2005
On Tue, 20 Sep 2005 17:59:03 GMT, "Darren" <> wrote
or quoted :

> archive = "Helloserver.jar"
> code = "Helloserver.class"


An Applet should always have a package. Also be careful. Java and some
servers are case sensitive. To avoid getting bitten, I consistently
use a convention:

1. packages are always lower case.
2. jar names are always lower case.
3. classes always start with a capital letter.

e.g.

code="com.mindprod.wassup.Wassup.class"
archive="wassup.jar"
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      09-20-2005
On Tue, 20 Sep 2005 17:59:03 GMT, "Darren" <> wrote
or quoted :

>load: class Helloserver.class not found.


look in your jar. Is the class in there with no package, spelled
EXACTLY like that including case. Use Winzip or the like to peek.

JarLook will produce a list of what is in a jar.


see http://mindprod.com/products1.html#JARLOOK
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      09-20-2005
On Tue, 20 Sep 2005 17:59:03 GMT, "Darren" <> wrote
or quoted :

>now when i put the class file instead of the jar and removed the jar file
>and the archive tag from the html file the class loads ok but again i get
>the security problems.


Obviously. You can't sign a class file, only a jar.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
Darren
Guest
Posts: n/a
 
      09-20-2005

"Roedy Green" <look-> wrote in message
news:...
> On Tue, 20 Sep 2005 17:59:03 GMT, "Darren" <> wrote
> or quoted :
>
> > archive = "Helloserver.jar"
> > code = "Helloserver.class"

>
> You don't post a class without a package. That is only for
> experimenting. I suspect signing presumes packages.

by package you mean like 'java.net' or 'java.io'?
does my package name need to be in a similar format?
how do i include it in my html applet tag?

> --
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Again taking new Java programming contracts.



 
Reply With Quote
 
Darren
Guest
Posts: n/a
 
      09-20-2005

"Roedy Green" <look-> wrote in message
news:...
> On Tue, 20 Sep 2005 17:59:03 GMT, "Darren" <> wrote
> or quoted :
>
> > codebase = "."

>
> that does not do anything. Just leave it out.

Will do. Wasn't sure if java was finnicky about such things.
> --
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Again taking new Java programming contracts.



 
Reply With Quote
 
Darren
Guest
Posts: n/a
 
      09-20-2005

"Roedy Green" <look-> wrote in message
news:...
> On Tue, 20 Sep 2005 17:59:03 GMT, "Darren" <> wrote
> or quoted :
>
> > archive = "Helloserver.jar"
> > code = "Helloserver.class"

>
> An Applet should always have a package. Also be careful. Java and some
> servers are case sensitive. To avoid getting bitten, I consistently
> use a convention:
>
> 1. packages are always lower case.
> 2. jar names are always lower case.
> 3. classes always start with a capital letter.
>
> e.g.
>
> code="com.mindprod.wassup.Wassup.class"
> archive="wassup.jar"


How is the com.mindprod.wassup constructed. Is it something you made up on
bespoke or is there a reason the syntax is like that? Also when i put
package in my applet. e.g 'package helloserver;' it creates a subdirector
called helloserver and i suspect if i were to call my package
"com.g7wap.helloserver" it would create a directory tree starting with com
then one below would be g7wap and the one below would be helloserver. if
this is the case then how would i reflect this in the jar archive? would jar
create the directory structure automatically based on the "package" entry in
the applet?
> --
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Again taking new Java programming contracts.



 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      09-20-2005
"Darren" <> wrote in message
news:Uz_Xe.11826$...
> by package you mean like 'java.net' or 'java.io'?
> does my package name need to be in a similar format?
> how do i include it in my html applet tag?


Here's a tutorial on how to use packages in java:

http://jarticles.com/package/package_eng.html

- Oliver


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Signed Applet vs Editing Java Policy file Krist Java 3 05-15-2010 04:25 AM
Convert a signed binary number into a signed one ? Rob1bureau VHDL 1 02-27-2010 12:13 AM
signed(12 downto 0) to signed (8 downto 0) kyrpa83 VHDL 1 10-17-2007 06:58 PM
Java applet failed when I try to load the avi file in my java applet Krista Java 3 09-15-2004 02:53 AM
Cannot use JavaScript to launch a signed Java applet Terri I. Java 3 09-04-2003 09:30 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57