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.

cweiske
  • 30,033
  • 14
  • 133
  • 194

5 Answers5

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.

Stephan
  • 4,395
  • 3
  • 26
  • 49
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.

Marcelo
  • 4,580
  • 7
  • 29
  • 46
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.

Jayan
  • 18,003
  • 15
  • 89
  • 143
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.

Juzer Ali
  • 4,109
  • 3
  • 35
  • 62
  • App Engine or any other server, really. It's just an UI technology, the whole server part extends standard servlets. – Marcelo Feb 14 '12 at 08:17
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.

Community
  • 1
  • 1