Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > run applet directly from browser

Reply
Thread Tools

run applet directly from browser

 
 
anuragsinghrajput@gmail.com
Guest
Posts: n/a
 
      02-06-2009
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???????????????????
 
Reply With Quote
 
 
 
 
John B. Matthews
Guest
Posts: n/a
 
      02-06-2009
In article
<36217ea8-e156-44a3-87a8->,
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?

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
 
Reply With Quote
 
 
 
 
anuragsinghrajput@gmail.com
Guest
Posts: n/a
 
      02-07-2009
On Feb 6, 6:02*pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
> In article
> <36217ea8-e156-44a3-87a8-5964bc825...@s1g2000prg.googlegroups.com>,
> *anuragsinghraj...@gmail.com 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?
>
> --
> John B. Matthews
> trashgod at gmail dot com
> <http://sites.google.com/site/drjohnbmatthews>


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.newInsta nce0(Native
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(Unknown
Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(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(Unk nown 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.newInsta nce0(Native
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(Unknown
Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(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.
 
Reply With Quote
 
John B. Matthews
Guest
Posts: n/a
 
      02-07-2009
In article
<9e1013e1-ae5a-4bcc-8fe8->,
wrote:

> On Feb 6, 6:02Â*pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
> > In article
> > <36217ea8-e156-44a3-87a8-5964bc825...@s1g2000prg.googlegroups.com>,
> > Â*anuragsinghraj...@gmail.com 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]
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
 
Reply With Quote
 
anuragsinghrajput@gmail.com
Guest
Posts: n/a
 
      02-10-2009
On Feb 7, 9:55*pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
> In article
> <9e1013e1-ae5a-4bcc-8fe8-f005949c9...@a12g2000pro.googlegroups.com>,
>
>
>
>
>
> *anuragsinghraj...@gmail.com wrote:
> > On Feb 6, 6:02*pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
> > > In article
> > > <36217ea8-e156-44a3-87a8-5964bc825...@s1g2000prg.googlegroups.com>,
> > > *anuragsinghraj...@gmail.com 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]
> --
> John B. Matthews
> trashgod at gmail dot com
> <http://sites.google.com/site/drjohnbmatthews>


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.
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      02-10-2009
On Feb 10, 4:29 pm, anuragsinghraj...@gmail.com wrote:

> 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'.

--
Andrew T.
PSCode.org
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      02-10-2009
On Fri, 6 Feb 2009 23:33:59 -0800 (PST),
wrote, quoted or indirectly quoted someone who said :

>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
 
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
why we should call Thread.start(),not directly call Thread.run()? junzhang1983@gmail.com Java 5 06-20-2008 03:12 PM
Can Java program evoke and run a FORTRAN program directly? Shawn Java 2 12-06-2006 07:08 PM
Preview image directly on PC, save directly to HD Patrick M. Digital Photography 3 01-07-2004 08:29 PM
applet wont run in browser James David Miller Java 10 11-04-2003 01:48 PM
Run server/s directly off CD? Andrew Thompson Java 5 08-17-2003 07:29 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