aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Call a local shared library from browser? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Call a local shared library from browser?" Watch "Call a local shared library from browser?" New topic
Author

Call a local shared library from browser?

Bret Waldow
Ranch Hand

Joined: Aug 04, 2000
Posts: 59
Hello,

I have a local shared library on a GNU/ Linux system - I can call it from a C program with a string, it does a computation and returns a string result. I can also call it from Java using JNA.

Is there a way to call it from JavaScript in a webpage from a local browser (Firefox, or Chrome)? Perhaps via GWT or suchlike?

Thanks for suggestions.

Cheers,
Bret
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

Not directly. You can use an Ajax request to fire off a server-side resource to execute it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bret Waldow
Ranch Hand

Joined: Aug 04, 2000
Posts: 59
Bear Bibeault wrote:Not directly. You can use an Ajax request to fire off a server-side resource to execute it.


Thanks.

I'm interested in more ideas like this, but I'm also interested in doing it without any server.

I'd like to know if there is a way I can call that library without any server, as a browser will let me load and run local content from the file system without one - and the browser includes a Javascript engine to run locally based code. I want to leverage the substantial abilities current browsers have to work with local content for a browser-based application.

I know the user can load files from the local system without a server. Can I access a local system library without a server? Can I get a remote page from the internet in another tab, and drag content off it to another locally stored page? This seems likely, as I can copy images off a web page from Firefox and save them.

I might also find reason to have a server for some other functionality as I develop my application, but knowing the limits of Javascript will be helpful, so I'd like to hear about both approaches - with and without.

Cheers,
Bret
Cloudgen C.F. Wong
Greenhorn

Joined: Jul 15, 2009
Posts: 19
Bret Waldow wrote:
Bear Bibeault wrote:Not directly. You can use an Ajax request to fire off a server-side resource to execute it.


Thanks.

I'm interested in more ideas like this, but I'm also interested in doing it without any server.

I'd like to know if there is a way I can call that library without any server, as a browser will let me load and run local content from the file system without one - and the browser includes a Javascript engine to run locally based code. I want to leverage the substantial abilities current browsers have to work with local content for a browser-based application.

I know the user can load files from the local system without a server. Can I access a local system library without a server? Can I get a remote page from the internet in another tab, and drag content off it to another locally stored page? This seems likely, as I can copy images off a web page from Firefox and save them.

I might also find reason to have a server for some other functionality as I develop my application, but knowing the limits of Javascript will be helpful, so I'd like to hear about both approaches - with and without.

Cheers,
Bret

If you can use your library within JNI, is it possible for you to wrap the libraries into RMI (Remote Method Invocation), or a network service, (or xmlrpc web services or something else) and allow it to be called by Java Applet (or xmlHttpRequest Object) in a webpage? (Java Applet or xmlHttpRequest Object have their own security limitations, too.)
If you target for ie as your webbrowser, you have an alternative choice, compile it as ActiveX dll component. And you can call it by <object></object> tag and access it using Javascript.

Moreover, you are not allow to access local system's resources (other than webpages, multimedia files and files that opened by webbrowser's plugin or add-ons) directly from Javascript due to security reasons. Thus, it's quite IMPOSSIBLE to call an external library directly from javascript.


cheers
Bret Waldow
Ranch Hand

Joined: Aug 04, 2000
Posts: 59
Cloudgen C.F. Wong wrote:
Bret Waldow wrote:I might also find reason to have a server for some other functionality as I develop my application, but knowing the limits of Javascript will be helpful, so I'd like to hear about both approaches - with and without.

Cheers,
Bret

If you can use your library within JNI, is it possible for you to wrap the libraries into RMI (Remote Method Invocation), or a network service, (or xmlrpc web services or something else) and allow it to be called by Java Applet (or xmlHttpRequest Object) in a webpage? (Java Applet or xmlHttpRequest Object have their own security limitations, too.)
If you target for ie as your webbrowser, you have an alternative choice, compile it as ActiveX dll component. And you can call it by <object></object> tag and access it using Javascript.

Moreover, you are not allow to access local system's resources (other than webpages, multimedia files and files that opened by webbrowser's plugin or add-ons) directly from Javascript due to security reasons. Thus, it's quite IMPOSSIBLE to call an external library directly from javascript.


Thanks. It appears from these responses I must provide a server-side component to provide access to local system services. I am already accessing the system library I mention via JNA from a Java app, so it shouldn't be too difficult to make it available via a server.

I did post a question here about how to deal with the possibility the user has already installed a server. If you have thoughts about that, I'd appreciate hearing them.

Thanks,
Bret
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

You might also consider signed applets.

Browsers do not allow access to local files and libraries due to security considerations. Imagine the nightmare of this were not so.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Call a local shared library from browser?