GWT interoperability: invoke java applet from GWT generated javascript - java

Since GWT is cross-compiled to javascript, only a few JRE packages are emulated. What if I need to make complex computations with packages not supported by the GWT x-compiling?
Is there a way to create a separate java app that can be invoked from the client side GWT (which would of course need to be shipped with the client). I don't want to ask the server to compute stuff that can be done by the client.
For example, I have a computer imaging library that could perform stuff for me without invoking the remote server.
Thank you.

If you can do something using pure Javascript/Javascript library you can use it straightway within GWT using JSNI. JSNI is basically a bridge to write Javascript within client side java code. Thus if you find yourself stuck trying to figure out how to do things in GWT which can easily be achieved using Javascript, either using plain Javascript or using 3rd party Javascript libraries, use JSNI.

Related

How to pass dictionary in c# as parameter to the soap web service method implemented in java [duplicate]

I have a Java API in jar file with some dependencies from other jar files.
Is there any way to call a specific method from this API, like using PInvoke from .NET?
Here you go :) I've used it myself and was very please with the implementation.
IKVM: Using Java API's in .NET Applications
(1) If you just want some libraries
from Java.
(2.1) If you have access to
the code.
(2.2) Last resort,
dynamically load the Java into .Net
(interpreter)
I don't think it will be an easy task to interoperate .net and java. May be you could use sockets, and use them to send messages from one environment to another. It is just an idea, though.
EDIT:
I have found some libs that say they can do this:
http://www.jnbridge.com/
http://www.codeproject.com/KB/dotnet/Espresso.aspx
You can use CORBA to "call" java methods from .NET.
For .NET here you can find some CORBA libraries.
Java SDK includes CORBA capabilities so you don't have to download 3rd party libraries.

how to call a remote java class(method)

I have a java based software and my client wants to load some data to the software using a different tool. I need to write a java module that can speak with both and acts as a mediator. How do I pass inputs from 3rd party tool to the my java based software?
If I could invoke any class(in java based software) from eclipse using the remote invocation then it would suffice my need.
I have never worked on remote invocation.
Well, you could look into using Java RMI.
However, this is usually done with Web Service http calls now.
I think most people would recommend using a RESTful solution and passing JSON representations of your objects back and forth between the two distributed systems.

Server and client side frameworks

I know this a fairly common question but after reading a lot I still can't understand this concept.
What I understand so far is that the main difference about a server side and a client side language is that the first one needs to be interpreted by the server to be sent to browser and the second one doesn´t.
I've worked with Vaadin and I know that is a server side framework because the java code needs to be interpreted to HTML and Javascript to be sent to browser. But then I've read that GWT is a client side and I can't understand why because we design all the page elements with Java widgets and they need to be interpreted to HTML and Javacript right? So, shouldn't GWT be a server side framework?
And what about JSF? I'm working with Primefaces and I develop xhtml files that uses beans to get server information. That means that the xhml files are client side and the Java beans are server side right?
Thanks!
It's not about the language the code is written, it's about where it runs.
GWT is a client-side technology just like TypeScript or CoffeeScript: they first have to be compiled or transpiled (a true compilation in the case of GWT) to JavaScript. The compilation has to be done at build time, before you deploy the app to your server. Once compiled to JavaScript, you don't need a server: the scripts can be packaged into browser extensions, mobile apps, or just run out of the filesystem (or be deployed to a Node.js server to run as server-side code !).
You can draw a parallel with Dart: dart2js converts Dart code to JavaScript so it can run in the browser, and/or you can run Dart code in a DartVM on the server side.
JSF is a server-side technology: things run in the server and generate code (HTML, JavaScript, CSS) to be interpreted by the browser (client).
I can't really tell for Vaadin as I don't know its architecture. If GWT Widgets have to be compiled upfront, then it'd be a server-side technology, generating highly dynamic web pages (so they could even run offline). If it compiles GWT widgets on-the-fly, then it'd be a bit in between; but it's primarily a server-side technology.
Vaadin use GWT to keep client-side code base in Java. GWT compiles Java code into browser dependent JavaScript. Without GWT all code should be written in JS. Vaadin is RIA application framework, so managing complex widgets code (look into Table source code) with pure JavaScript would be painful and not easy. You can write some logic in client side and also you can use pure JavaScript in Vaadin7. It's easy to extend and gives solid foundations to write good and rich UI with minimal use of the JavaScript.

how to use java based project in firebreath plugin framework

I am trying to develop a HTML5 plugin using NPAPI and firebreath framework. The code which needs to be used, is written in java but I need to convert it into C++. The only way i know is via JNI where i need to convert each .java file into .cpp file. However there are over 200 files in my project. Is there a better way to achieve this??
Any "simple" way would be more of a c++ question than a plugin or firebreath question. My guess is that you'd be far better off just making it an applet rather than a plugin if you want it mainly in java. There is nothing that I'm aware of that will make it easy for you to do what you want to do using FireBreath or NPAPI directly.
JNI doesn't convert Java to C++, it is a technology for calling native code (such as C or C++) from Java code. It doesn't seem relevant to your problem: Either you (manually or robotically) convert all your Java to C++ (which you can then call from Firebreath), or you keep your code in Java and run an applet (with no C/C++ code involved.)
If an applet as suggested by #taxilian isn't a good choice, why not turn your Java project into an application, and have your Firebreath plugin launch that and communicate with it? Your plugin could even download and install the Java app, for example in a temp folder. One limitation: The Java code won't have any direct access to internal browser API's, the Firebreath plugin would have to make any such calls on behalf of the Java app. How hard this all is would mainly depend on the complexity and bandwidth of communication needed between the web page and the Java code.

Best solution for using EJBs from Excel

We would like to give access to some of our EJBs from Excel. The goal is to give an API usable from VBA.
Our EJBs are mostly Stateless Session Beans that do simple CRUD operations with POJOs.
Some possible solutions:
Exposing the EJBs as WebServices and create a VB/C# dll wrapping them,
Using Corba to access the EJBs from C#,
Creating a COM Library that uses Java to access the EJBs,
Pointers to frameworks for these solution or other ideas are welcome.
You could take a look at IIOP.NET, which addresses this issue.
If you have a fairly recent ejb container, the cheapest and easiest should be to expose your beans as web services and call it from VB/C#. This doesn't require any extra tool or library.
I work on an open source project called XLLoop - this framework allows you to expose POJO functions as Excel functions.
It consists of:
An Excel add-in (XLL), which communicates over TCP to:
A Java server/library, which invokes java methods.
You could embed this java function server in an EJB and have it deployed as part of your app server.
Back in the VB6/COM/DCOM times we used the suite J-Integra to accomblish this task. I have no experience with the .NET version though.
I highly recommend IKVM. It is a java byte code to .NET assembly compiler (i.e. JAR --> DLL) and I have used it to create live JMX links and listeners in an Excel automation server. It should not be difficult for you to create a .NET assembly of your EJB client stubs and supporting libraries.
//Nicholas
You could try Obba (I work on this project):
Obba is a Java object handler for spreadsheet applications.
It provides a bridge between spreadsheets and Java classes, such that spreadsheets can be used as graphical user interface for Java libraries. Accessing your Java library form the spreadsheet requires no glue code (no VBA needed, no special Java code needed). Objects are instantiated by their original constructor. Constructors and methods are invoked using a "by name" reflection. A spreadsheet-specific factory method is not necessary. Obba provides the functions to handle objects in spreadsheets.
The Java virtual machine providing the add-in may run on the same computer or a remote computer - without any change to the spreadsheet, i.e., object referenced in the spreadsheet can reside on remote Java virtual machine.

Categories

Resources