I'm not a web programmer (C++ and Java for me), so creating a website looked like it required learning more internet-centric languages (javascript, PHP, etc). Then I found GWT, which looks fantastic- I can program javascript without having to learn another language. GWT requires all Java sources to be present to translate them to javascript- no JAR's or other libraries. So, would it be possible to have the generated javascript call into some actual Java bytecode to be executed client or serverside?
-
I dont think you can do that. It is a web framework, and for developing browser based applications. So, you may be able to interact with existing Javascript, but definitely not Java bytecodes... unless you are talking JSON etc. in which case you can interact with anything, not necessarily Java :Pgovi– govi2011-04-18 00:03:01 +00:00Commented Apr 18, 2011 at 0:03
1 Answer
For code that you want to have executed on the client side, GWT's java-to-javascript compiler needs to be able to see the Java source code (via an entry in your GWT module XML file or another one that it inherits), and that source needs to only use types and methods in a limited but clearly specified subset of the JRE API.
If all you have access to is the compiled bytecode for some library that you need to invoke, you will need to invoke it on the server side. There are multiple ways to have the client invoke code on the server, the easiest being GWT's RPC mechanism.