We help IT Professionals succeed at work.

HTML Code for calling Applet in a Jar

pshortland
pshortland asked
on
3,661 Views
Last Modified: 2010-05-18
Final question of the day !
 I have a signed .jar file. It contains my applet (class) and the SQL driver.

My first attempt to use it....
<APPLET
  CODEBASE = "."
  CODE     = "app2.sqlapp.class"
  NAME     = "TestApplet"
  WIDTH    = 800
  HEIGHT   = 300
  HSPACE   = 0
  VSPACE   = 0
  ALIGN    = top
  archive  = "jtds-1.2.jar">
>
</APPLET>

Gives a network error, and my second
<APPLET
  CODEBASE = "."
  CODE     = "app2.sqlapp.class"
  NAME     = "TestApplet"
  WIDTH    = 800
  HEIGHT   = 300
  HSPACE   = 0
  VSPACE   = 0
  ALIGN    = top
  archive  = "app2.jar">
>
</APPLET>

gives a class not found error.

The jar is app2.jar, the class is app2.sqlapp.class and the driver is jtds-1.2.jar.
Is either html code correct ? If not what needs fixing ?

Thanks !
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016

Commented:
You need to use the archive attribute in the tag
CERTIFIED EXPERT
Top Expert 2016

Commented:
ARCHIVE     = "ap2.jar,jtds-1.2.jar"

Author

Commented:
I have, its the last one !
archive  = "app2.jar">
CERTIFIED EXPERT
Top Expert 2016

Commented:
Sorry

ARCHIVE     = "app2.jar,jtds-1.2.jar"
CERTIFIED EXPERT
Top Expert 2016

Commented:
Ah yes, i missed it ;-) BUT - you need both in there

Author

Commented:
Ok, I now have...

<APPLET
  CODEBASE = "."
  CODE     = "app2.sqlapp.class"
  NAME     = "TestApplet"
  WIDTH    = 800
  HEIGHT   = 300
  HSPACE   = 0
  VSPACE   = 0
  ALIGN    = top
  archive  = "app2.jar,jtds-1.2.jar">
>
</APPLET>


If it's correct then I have another issue as I am getting a network error.
Is the html correct ?
CERTIFIED EXPERT
Top Expert 2016

Commented:
>>as I am getting a network error.

What error

>>Is the html correct ?

Impossible to say with certainty that the paths are right. Are the jars in the same dir as the html?
Are the class and package names correct?
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
you need to sign both the jars

Author

Commented:
Both now signed, same error :o(
CERTIFIED EXPERT
Top Expert 2016

Commented:
Make sure the applet cache is empty. Then postthe error
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
> Both now signed, same error :o(

are you getting pronmpted to grant perms to the applet (and are u accepting
if not theres a problem with the signing or you're running old jars.
restartr the browser and ensure you are loadinmg the new jars
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
and test it first using appletviewer

Author

Commented:
Ok, a new browser used and we get a security pop up asking if i want to run the app. Clicking run then loads the applet but it fails with the same message.

Tested AOk in JBuilder.
CERTIFIED EXPERT
Top Expert 2016

Commented:
The message you keep failing to post you mean? ;-)

Author

Commented:
Soory !

This one

java.sql.SQLException: Network error IOException: Could not create socket

Author

Commented:
Network chaps here confirm the web server can contact the sql server on port 1433.

Any ideas to try ?
CERTIFIED EXPERT
Top Expert 2016

Commented:
OK - there should be a stack trace though - open the plugin console and post it please
CERTIFIED EXPERT
Top Expert 2016

Commented:
You also turn up debugging in the console. Shall be away from here for a while

Author

Commented:
'OK - there should be a stack trace though - open the plugin console and post it please'

I have no idea what that means :o)
CERTIFIED EXPERT
Top Expert 2016

Commented:
RIght click the Java icon in the system tray and bring up the console

Author

Commented:
Now we like that !

Java Plug-in 1.6.0_01
Using JRE version 1.6.0_01 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\shortp01


----------------------------------------------------
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
p:   reload proxy configuration
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 <n>
----------------------------------------------------

java.sql.SQLException: Network error IOException: Could not create socket
      at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:372)
      at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
      at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:178)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at app2.sqlapp$Select.getData(sqlapp.java:49)
      at app2.sqlapp.init(sqlapp.java:24)
      at sun.applet.AppletPanel.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: Could not create socket
      at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:303)
      at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:250)
      at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:297)
      ... 8 more
Caused by: java.security.AccessControlException: access denied (java.net.SocketPermission DHSQL05 resolve)
      at java.security.AccessControlContext.checkPermission(Unknown Source)
      at java.security.AccessController.checkPermission(Unknown Source)
      at java.lang.SecurityManager.checkPermission(Unknown Source)
      at java.lang.SecurityManager.checkConnect(Unknown Source)
      at java.net.InetAddress.getAllByName0(Unknown Source)
      at java.net.InetAddress.getAllByName0(Unknown Source)
      at java.net.InetAddress.getAllByName(Unknown Source)
      at java.net.InetAddress.getByName(Unknown Source)
      at java.net.InetSocketAddress.<init>(Unknown Source)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:283)
      ... 10 more
CERTIFIED EXPERT
Top Expert 2016

Commented:
Driver jar not signed
Java Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Sorry, off work today. Will get onto it in the morning !

Author

Commented:
Objects got this one !
Moved from init to start and works like a dream, many thanks !
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.