Connecting Tech Pros Worldwide Help | Site Map

Calling a DLL from a Java Applet

Rowland
Guest
 
Posts: n/a
#1: Jul 18 '05
Hi,

I know this question has prob. been asked a million times, but I couldn't
find it in the FAQ, so here goes :

I'm trying to write a Java applet to call a dll that resides on the web
server (running IIS 6). I've written a little test applet that should call a
helloWorld function in the dll, but when I use System.loadLibrary, it gives
me this security warning :

java.security.AccessControlException : access denied
(java.lang.RuntimePermission loadLibrary.myLib)

I've read that it's not possible to run a dll on a client computer (except
perhaps by signing it?), but I can't find much information about dll's on a
web server. If anyone could give me any pointers, I'd really appreciate it
:-)

Thanks,

Rowland.


Raymond DeCampo
Guest
 
Posts: n/a
#2: Jul 18 '05

re: Calling a DLL from a Java Applet


Rowland wrote:[color=blue]
> Hi,
>
> I know this question has prob. been asked a million times, but I couldn't
> find it in the FAQ, so here goes :
>
> I'm trying to write a Java applet to call a dll that resides on the web
> server (running IIS 6). I've written a little test applet that should call a
> helloWorld function in the dll, but when I use System.loadLibrary, it gives
> me this security warning :
>
> java.security.AccessControlException : access denied
> (java.lang.RuntimePermission loadLibrary.myLib)
>
> I've read that it's not possible to run a dll on a client computer (except
> perhaps by signing it?), but I can't find much information about dll's on a
> web server. If anyone could give me any pointers, I'd really appreciate it
> :-)
>[/color]

The applet runs on the client. If the applet spawns code, be it from a
jar, a dll or whatever, the code runs on the client. Therefore it would
be a security issue to allow the applet to execute code from a dll no
matter where the dll came from.

Now, did you want the dll code to be executed on the client or the
server? If you want the client, you'll have to sign the applet and I
would expect things to get messy. If you want the code to execute on
the server, then you need to write some sort of server program (servlet,
web service, simple socket-based server, etc.) to execute the code.
Then make the applet a client of that server.

Ray

--
XML is the programmer's duct tape.
Quiks
Guest
 
Posts: n/a
#3: Jul 18 '05

re: Calling a DLL from a Java Applet


Have you tried to sign your applet ??? It solved the problem for me
when I tried exchanging SOAP data over SSL..... and even using an XML
parser requested my applet to be signed. It MAY solve your problem.
Let me know if it did!

Quiks
--------------
BTW: For those who have to do with monitoring, check the site:
http://www.metamindsolutions.com. It's a great multiplatform
monitoring solution and seems to have been adopted by large accounts


"Rowland" <banksr0@hotmail.com> wrote in message news:<cgn9bg$2i$1@hercules.btinternet.com>...[color=blue]
> Hi,
>
> I know this question has prob. been asked a million times, but I couldn't
> find it in the FAQ, so here goes :
>
> I'm trying to write a Java applet to call a dll that resides on the web
> server (running IIS 6). I've written a little test applet that should call a
> helloWorld function in the dll, but when I use System.loadLibrary, it gives
> me this security warning :
>
> java.security.AccessControlException : access denied
> (java.lang.RuntimePermission loadLibrary.myLib)
>
> I've read that it's not possible to run a dll on a client computer (except
> perhaps by signing it?), but I can't find much information about dll's on a
> web server. If anyone could give me any pointers, I'd really appreciate it
> :-)
>
> Thanks,
>
> Rowland.[/color]
Rowland
Guest
 
Posts: n/a
#4: Jul 18 '05

re: Calling a DLL from a Java Applet


"Raymond DeCampo" <rdecampo@spam.twcny.spam.rr.spam.com.spam> wrote in
message news:NWPXc.48340$Kt5.16083@twister.nyroc.rr.com...[color=blue]
> Rowland wrote:[color=green]
> > Hi,
> >
> > I know this question has prob. been asked a million times, but I[/color][/color]
couldn't[color=blue][color=green]
> > find it in the FAQ, so here goes :
> >
> > I'm trying to write a Java applet to call a dll that resides on the web
> > server (running IIS 6). I've written a little test applet that should[/color][/color]
call a[color=blue][color=green]
> > helloWorld function in the dll, but when I use System.loadLibrary, it[/color][/color]
gives[color=blue][color=green]
> > me this security warning :
> >
> > java.security.AccessControlException : access denied
> > (java.lang.RuntimePermission loadLibrary.myLib)
> >
> > I've read that it's not possible to run a dll on a client computer[/color][/color]
(except[color=blue][color=green]
> > perhaps by signing it?), but I can't find much information about dll's[/color][/color]
on a[color=blue][color=green]
> > web server. If anyone could give me any pointers, I'd really appreciate[/color][/color]
it[color=blue][color=green]
> > :-)
> >[/color]
>
> The applet runs on the client. If the applet spawns code, be it from a
> jar, a dll or whatever, the code runs on the client. Therefore it would
> be a security issue to allow the applet to execute code from a dll no
> matter where the dll came from.
>
> Now, did you want the dll code to be executed on the client or the
> server? If you want the client, you'll have to sign the applet and I
> would expect things to get messy. If you want the code to execute on
> the server, then you need to write some sort of server program (servlet,
> web service, simple socket-based server, etc.) to execute the code.
> Then make the applet a client of that server.
>
> Ray
>
> --
> XML is the programmer's duct tape.[/color]

Thanks very much for you response - I'll explain the problem and you might
be able to guide me in the right direction :-).

Basically, I'm writing an administration program for a database. I've
already written the program in VB, but our client wants to convert it so
that it will be deployed from their web-server. For this reason it was
decided to investigate Java. However, to save time (and for other reasoons),
I was hoping to be able to use an existing DLL within the Java program. I've
done this with a Java application before, but I've very little experience
with applets, servlets, etc. The dll will be executing code to talk to a
database, so it would prob. be best to have it server side for security.

So my question is this : What would be the best way to solve this problem.
Can I have a client applet written using the AWT talking to a server servlet
using my dll? Are there other, better options?

Many thanks,

Rowland.


Rowland
Guest
 
Posts: n/a
#5: Jul 18 '05

re: Calling a DLL from a Java Applet


"Rowland" <banksr0@hotmail.com> wrote in message
news:ch1iuc$ji3$1@sparta.btinternet.com...[color=blue]
> "Raymond DeCampo" <rdecampo@spam.twcny.spam.rr.spam.com.spam> wrote in
> message news:NWPXc.48340$Kt5.16083@twister.nyroc.rr.com...[color=green]
> > Rowland wrote:[color=darkred]
> > > Hi,
> > >
> > > I know this question has prob. been asked a million times, but I[/color][/color]
> couldn't[color=green][color=darkred]
> > > find it in the FAQ, so here goes :
> > >
> > > I'm trying to write a Java applet to call a dll that resides on the[/color][/color][/color]
web[color=blue][color=green][color=darkred]
> > > server (running IIS 6). I've written a little test applet that should[/color][/color]
> call a[color=green][color=darkred]
> > > helloWorld function in the dll, but when I use System.loadLibrary, it[/color][/color]
> gives[color=green][color=darkred]
> > > me this security warning :
> > >
> > > java.security.AccessControlException : access denied
> > > (java.lang.RuntimePermission loadLibrary.myLib)
> > >
> > > I've read that it's not possible to run a dll on a client computer[/color][/color]
> (except[color=green][color=darkred]
> > > perhaps by signing it?), but I can't find much information about dll's[/color][/color]
> on a[color=green][color=darkred]
> > > web server. If anyone could give me any pointers, I'd really[/color][/color][/color]
appreciate[color=blue]
> it[color=green][color=darkred]
> > > :-)
> > >[/color]
> >
> > The applet runs on the client. If the applet spawns code, be it from a
> > jar, a dll or whatever, the code runs on the client. Therefore it would
> > be a security issue to allow the applet to execute code from a dll no
> > matter where the dll came from.
> >
> > Now, did you want the dll code to be executed on the client or the
> > server? If you want the client, you'll have to sign the applet and I
> > would expect things to get messy. If you want the code to execute on
> > the server, then you need to write some sort of server program (servlet,
> > web service, simple socket-based server, etc.) to execute the code.
> > Then make the applet a client of that server.
> >
> > Ray
> >
> > --
> > XML is the programmer's duct tape.[/color]
>
> Thanks very much for you response - I'll explain the problem and you might
> be able to guide me in the right direction :-).
>
> Basically, I'm writing an administration program for a database. I've
> already written the program in VB, but our client wants to convert it so
> that it will be deployed from their web-server. For this reason it was
> decided to investigate Java. However, to save time (and for other[/color]
reasoons),[color=blue]
> I was hoping to be able to use an existing DLL within the Java program.[/color]
I've[color=blue]
> done this with a Java application before, but I've very little experience
> with applets, servlets, etc. The dll will be executing code to talk to a
> database, so it would prob. be best to have it server side for security.
>
> So my question is this : What would be the best way to solve this problem.
> Can I have a client applet written using the AWT talking to a server[/color]
servlet[color=blue]
> using my dll? Are there other, better options?
>
> Many thanks,
>
> Rowland.
>[/color]
Scratch that - I think I've found the way that will work best for me. I have
a client applet as before, but I also have a server listening on port nnn
for commands from this client. The client creates a socket connection to the
server (which would have to be the same server as the client class files are
located on due to applet security restrictions) which 'does stuff' based on
what commands are passed to it.

I found a good tutorial on how to set up the basics here:
http://www.javaworld.com/javaworld/j...ockets-p2.html

If this idea won't work, I'd be grateful if someone points it out to me
before I get too far into developing it ;-)

Thanks,

Rowland.



Raymond DeCampo
Guest
 
Posts: n/a
#6: Jul 18 '05

re: Calling a DLL from a Java Applet


Rowland wrote:[color=blue]
> "Rowland" <banksr0@hotmail.com> wrote in message
> news:ch1iuc$ji3$1@sparta.btinternet.com...
>[color=green]
>>
>>Thanks very much for you response - I'll explain the problem and you might
>>be able to guide me in the right direction :-).
>>
>>Basically, I'm writing an administration program for a database. I've
>>already written the program in VB, but our client wants to convert it so
>>that it will be deployed from their web-server. For this reason it was
>>decided to investigate Java. However, to save time (and for other[/color]
>
> reasoons),
>[color=green]
>>I was hoping to be able to use an existing DLL within the Java program.[/color]
>
> I've
>[color=green]
>>done this with a Java application before, but I've very little experience
>>with applets, servlets, etc. The dll will be executing code to talk to a
>>database, so it would prob. be best to have it server side for security.
>>
>>So my question is this : What would be the best way to solve this problem.
>>Can I have a client applet written using the AWT talking to a server[/color]
>
> servlet
>[color=green]
>>using my dll? Are there other, better options?
>>
>>Many thanks,
>>
>>Rowland.
>>[/color]
>
> Scratch that - I think I've found the way that will work best for me. I have
> a client applet as before, but I also have a server listening on port nnn
> for commands from this client. The client creates a socket connection to the
> server (which would have to be the same server as the client class files are
> located on due to applet security restrictions) which 'does stuff' based on
> what commands are passed to it.
>
> I found a good tutorial on how to set up the basics here:
> http://www.javaworld.com/javaworld/j...ockets-p2.html
>
> If this idea won't work, I'd be grateful if someone points it out to me
> before I get too far into developing it ;-)
>
> Thanks,
>
> Rowland.
>[/color]

Rowland,

That should work fine; I think it is the best option if you are locked
into a Java front-end. You may also want to consider an ActiveX plug-in
for IE, it should be able to execute code from a DLL.

HTH,
Ray

--
XML is the programmer's duct tape.
Closed Thread