2

I am trying to write an extension to google chrome and I want to use my own java classes and it's attributes, methods inside a javascript code. I search on the internet but I did'nt find enough resources in terms of implementation. Can you give me any idea how to integrate and use my own java classes inside a javascript code. If you can help me , I will appreciate

Thanks.

5 Answers 5

1

This will not work. Both are totally different programming languages. Javascript is a script that is interpreted by the web browser. Java is a object oriented programming language that needs to be compiled and run in a virtual machine (JVM). Many people are confused by the similar names.

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

2 Comments

But I know that there are implementations about it.Isn't there any way to reach java code from javascript ?
You can use Java-JavaScript interaction libraries or getting use of JSON, JSObject etc.
1

Isn't Google Web Toolkit (GWT) what you are looking for? It translates code written in Java to native Javascript to be run on the browser.

I wonder if it would be possible to integrate the generated code with your code, to run it as a browser extension, though.

Comments

0

If you need only instance variables of your classes, you would do well by converting your object into JSON and sending it to you extension. Check http://www.json.org/java/index.html. As pointed out by Marcelo, GWT will help you but only if you are deploying your app on Google App Engine. It is not for chrome extensions.

1 Comment

App Engine or any other server, really. It's just an UI technology, the whole server part extends standard servlets.
0

I guess you wanted a bean like access from a scripting language to java 'objects'..

http://commons.apache.org/bsf/ may help you to access Java objects and methods from scripting languages. it claims to support javascript.

Comments

0

Mozilla has something like this through XP-COM.

also: see this, Chrome and XPCOM

I am wondering if you found a solution to this.

Comments

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.