1

I have a proprietary Java API, which I want to call from my HTML/Javascript application. So I'm considering to use WebView or similar component to embed WebKit into resulting Java application.

What would be the best way to implement interface between Javascript and Java? Can I easily extend window DOM object in Java?

I'm going to run the application on the desktop (most likely Windows 7), but it's good to have as portable as possible as in the future I'll need to run the same app on different devices.

3
  • Unfortunately stackoverflow.com/questions/48249/… and stackoverflow.com/questions/1454652/… do not fully answer my question. Commented Apr 30, 2012 at 9:29
  • Why did you accept an answer for the second one then? And check out my answer on the first. Commented Apr 30, 2012 at 9:38
  • That could be an answer to this question too. Commented Apr 30, 2012 at 9:39

1 Answer 1

1

If you don't want to use a server (which would make such a thing easy with ajax), you need to embed the javascript engine.

The best is probably to use the Rhino javascript engine (written entirely in java) :

http://www.mozilla.org/rhino/

There is also an integration of the very good V8 engine ( http://code.google.com/p/jav8/ ) but I don't know if this integration is complete or reliable.

Sign up to request clarification or add additional context in comments.

4 Comments

You could post this answer here: <stackoverflow.com/questions/48249/…> too
I was answering to "What would be the best way to implement interface between Javascript and Java". It seemed to me to be simpler not to integrate a browser (and I don't see the point to have two identical questions and answers so I think it's better to keep javascript engine in this question and to answer in the other one with the integration of browser). I agree with you, though, that the other question needs an acceptation. And I have some doubts and fears about the whole architecture of OP.
Thank you for the answer. My point is that I need both javascript engine and layout engine to run HTML/Javascript application inside my Java application. I may consider to use WebView without extending, simple web server running in the same application and let them communicate using ajax.
I think i'll go with stackoverflow.com/questions/1454652/… Here is very good set of example eclipse.org/swt/snippets/#browser

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.