run applet directly from browser

  • Thread starter anuragsinghrajput
  • Start date
A

anuragsinghrajput

Hello sir,

i have a applet program in netbeans, i imported two jar files, and the
project worked fine when i run it from netbeans.
The exact problem arised when i tried to deploy it to html file using
the following code:

<!--
Document : AnuApp
Created on : Jan 30, 2009, 4:50:23 PM
Author : Administrator
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
</head>
<body>
<APPLET
ARCHIVE = " log4j.jar, ActForexApi.jar "
CODE = Start.class
WIDTH = 600
HEIGHT = 400</APPLET>


</body>
</html>



In the above code, in the parameters "ARCHIVE" i need to use two jar
files, but its detecting only one.
What should i do???????????????????
 
J

John B. Matthews

(e-mail address removed) wrote something like:
[...]
I have an applet program in NetBeans. I imported two JAR files, and
the project worked fine when I ran it from NetBeans. The problem
arose when I tried to launch it using the following HTML file: [...]
<APPLET
ARCHIVE = " log4j.jar, ActForexApi.jar "
CODE = Start.class
WIDTH = 600
HEIGHT = 400
</APPLET>
[...]
In the above ARCHIVE parameter, I need to use two jar files, but it's
detecting only one. What should I do?

How did you determine that the applet container is loading only one JAR
file? Is the errant file name spelled correctly. Is your host file
system case sensitive? Are trailing spaces significant? Are more than
two JAR files required? Have you tried other containers?
 
A

anuragsinghrajput

 (e-mail address removed) wrote something like:
[...]
I have an applet program in NetBeans. I imported two JAR files, and
the project worked fine when I ran it from NetBeans. The problem
arose when I tried to launch it using the following HTML file: [...]
  <APPLET
    ARCHIVE =  " log4j.jar,  ActForexApi.jar "
    CODE = Start.class
    WIDTH = 600
    HEIGHT = 400
  </APPLET> [...]
In the above ARCHIVE parameter, I need to use two jar files, but it's
detecting only one. What should I do?

How did you determine that the applet container is loading only one JAR
file? Is the errant file name spelled correctly. Is your host file
system case sensitive? Are trailing spaces significant?  Are more than
two JAR files required? Have you tried other containers?

Hello Sir,


I tried to run the above applet program using a batch file with the
following code:


@echo off
set CLASSPATH="ActForexApi.jar";"log4j.jar";"."
java -cp %CLASSPATH% Start



and its working fine.
but when i'm trying to open it in web browser(IE7 or Mozilla3) with
the above given code, it throws following exceptions:


1)
----------------------------------------------------
java.lang.ExceptionInInitializerError
at SimpleTestApplet.<init>(SimpleTestApplet.java:69)
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 java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(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.security.AccessControlException: access denied
(java.lang.RuntimePermission shutdownHooks)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.Runtime.addShutdownHook(Unknown Source)
at actforex.api.TraderApi.<clinit>(TraderApi.java:53)
... 12 more


2)
--------------------------------------------------------------------------------------------
java.lang.NoClassDefFoundError: Could not initialize class
actforex.api.TraderApi
at SimpleTestApplet.<init>(SimpleTestApplet.java:69)
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 java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(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)

------------------------------
it throws the Exception no.1 sometimes, but generally it throws 2nd
exception,
once it throws the 2nd exception, it doesn't throws 1st exception, and
keeps on throwing 2nd exception.

2nd exception contains "actforex.api.TraderApi" which is a class in a
jar file included in archive.

i'm still trying.

what could be the reason that it runs from Batch File, but not from
Html File.
 
J

John B. Matthews

 (e-mail address removed) wrote something like:
[...]
I have an applet program in NetBeans. I imported two JAR files, and
the project worked fine when I ran it from NetBeans. The problem
arose when I tried to launch it using the following HTML file: [...]
  <APPLET
    ARCHIVE =  " log4j.jar,  ActForexApi.jar "
    CODE = Start.class
    WIDTH = 600
    HEIGHT = 400
  </APPLET> [...]
In the above ARCHIVE parameter, I need to use two jar files, but it's
detecting only one. What should I do?

How did you determine that the applet container is loading only one JAR
file? Is the errant file name spelled correctly. Is your host file
system case sensitive? Are trailing spaces significant?  Are more than
two JAR files required? Have you tried other containers?
[...]
I tried to run the above applet program using a batch file with the
following code:

@echo off
set CLASSPATH="ActForexApi.jar";"log4j.jar";"."
java -cp %CLASSPATH% Start

and its working fine. [...]
what could be the reason that it runs from Batch File, but not from
HTML File.

Sorry, I'm weak on DOS batch syntax, but I see that the HTML ARCHIVE
attribute contains spaces that aren't in the batch file's CLASSPATH.
Also, the latter contains the current directory, while the former does
not. Finally, the latter runs an application; perhaps the applet fails
perform the same initialization. Here is a simple example of a hybrid
that uses a single method to initialize the top-level container:

<http://sites.google.com/site/drjohnbmatthews/subway>

[Please trim signatures when replying]
 
A

anuragsinghrajput

 (e-mail address removed) wrote something like:
[...]
I have an applet program in NetBeans. I imported two JAR files, and
the project worked fine when I ran it from NetBeans. The problem
arose when I tried to launch it using the following HTML file:
[...]
  <APPLET
    ARCHIVE =  " log4j.jar,  ActForexApi.jar "
    CODE = Start.class
    WIDTH = 600
    HEIGHT = 400
  </APPLET>
[...]
In the above ARCHIVE parameter, I need to use two jar files, but it's
detecting only one. What should I do?
How did you determine that the applet container is loading only one JAR
file? Is the errant file name spelled correctly. Is your host file
system case sensitive? Are trailing spaces significant?  Are more than
two JAR files required? Have you tried other containers?
[...]
I tried to run the above applet program using a batch file with the
following code:
@echo off
set CLASSPATH="ActForexApi.jar";"log4j.jar";"."
java -cp %CLASSPATH% Start
and its working fine. [...]
what could be the reason that it runs from Batch File, but not from
HTML File.

Sorry, I'm weak on DOS batch syntax, but I see that the HTML ARCHIVE
attribute contains spaces that aren't in the batch file's CLASSPATH.
Also, the latter contains the current directory, while the former does
not. Finally, the latter runs an application; perhaps the applet fails
perform the same initialization. Here is a simple example of a hybrid
that uses a single method to initialize the top-level container:

<http://sites.google.com/site/drjohnbmatthews/subway>

[Please trim signatures when replying]

Hello Sir,

Thanks for your support, i understood the mistake.
Actually the Applet Project threw some exceptions as there was some
file missing.
Applet viewer was able to continue the execution of program with
exception,
but the Browsers do not allow to run the codes which throw exception,
same as the thing which happens when we run normal java codes, and JVM
do not execute them unless all the exceptions are cured.
Thanks.
 
A

Andrew Thompson

Hello Sir,

Please TRIM SIGS.
Thanks for your support, i understood the mistake.
Actually the Applet Project threw some exceptions as there was some
file missing.
Applet viewer was able to continue the execution of program with
exception,

I very much doubt that. AppletViewer is just as subject to stopping
on Exceptions and Errors as browsers are. The real difference is
probably that the AppletViewer is not imposing a security sandbox,
which means the 'missing' file is 'found'.
 
R

Roedy Green

Caused by: java.security.AccessControlException: access denied

You did something that requires a SIGNED applet. See
http://mindprod.com/jgloss/signedapplets.html
http://mindprod.com/jgloss/applet.html

It has nothing to do with having two jars.

It will be easiest to combine the jars and sign that jar.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Here is a point of no return after which warming becomes unstoppable
and we are probably going to sail right through it.
It is the point at which anthropogenic (human-caused) warming triggers
huge releases of carbon dioxide from warming oceans, or similar releases
of both carbon dioxide and methane from melting permafrost, or both.
Most climate scientists think that point lies not far beyond 2°C (4°F) C hotter."
~ Gwynne Dyer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top