This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Call a local shared library from browser?

 
Bret Waldow
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64828
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not directly. You can use an Ajax request to fire off a server-side resource to execute it.
 
Bret Waldow
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bret Waldow
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64828
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic