1

We have distributed web application and front-end part of this application should be standalone desktop application and have integration with desktop apps such as telephony. I saw Electron framework and apps (for instance Slack) built on top of it and it is pretty good.

Does Java world have such a tool for embedding of jetty/tomcat and webkit browser to built native desktop apps?

Similar questions:

Update: See my test application on Java CEF: https://github.com/jreznot/cefc.

It uses Jetty/Swing/JavaCEF/Vaadin as HTML 5 Desktop Stack.

Final Update:

See my Electron+Java madness: https://github.com/jreznot/electron-java-app

It uses Electron with Java server side and Vaadin for application UI.

I recommend to use Electron instead of Java-Webkit bindings because it is mature framework and it has large community of JS developers.

Community
  • 1
  • 1
jreznot
  • 2,694
  • 2
  • 35
  • 53
  • have you to embedded browser too? or you can make only a jar embedding jetty or tomcat and use a standard browser to display your app pointing it to localhost:portnumber/ ? –  Apr 22 '16 at 15:52
  • I want to embed some browser and jetty to one java application to have full control on desktop and backend in one JVM – jreznot Apr 23 '16 at 06:59

2 Answers2

0

I think you can use wt. This is a system that takes a Qt based GUI application and rewrites the drawing mechanism from the usual desktop controls into html controls on a web page. IIRC its very transparent in that you only need to change a line or two of your original code. Qt is not java though, so I'm only pointing it out for completeness, its still pretty cool though.


But the simplest way would be to implement it using web technologies (eg HTML/JSP controls) so that it can be displayed as a web page easily, and then create a desktop app that uses the same html pages only wrapped as a 'executable'.

To create a desktop application you can either view the web page in an embedded browser in an application that exists solely to show the browser in a window, or you can use something like Microsoft's HTA system that presents web pages as desktop-style windows.

Credit goes to @gbjbaanb

Resource Link:

  1. Is it possible to have a single code base for a desktop GUI and a web application?
  2. Run Jetty Web Server Within Your Application
  3. Running a web application (WAR) with embedded jetty server
Community
  • 1
  • 1
SkyWalker
  • 28,384
  • 14
  • 74
  • 132
  • In this case I cannot use Desktop API for opening new windows, adding tray icon in Java and most importantly I cannot communicate with Desktop part from Java backend using Java API – jreznot Apr 23 '16 at 11:57
  • @jreznot Have you check number 2 resource link? is it OK with you? – SkyWalker Apr 23 '16 at 12:03
  • I've just found official manual http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html, so embedding of Jetty is very simple – jreznot Apr 24 '16 at 13:50
  • @jreznot yes, that's a good tutorial. Number 2 is minified version of that tutorial. Thanks for sharing. – SkyWalker Apr 24 '16 at 14:31
0

I have search for similar solution in these last days and haven't found a totally fine solution.

These below is the more interesting partials solutions I have found.

Embed a browser (chromium) in java

I found two web site and is unclear what is the better solution:

I am not sure if these embedding solution will work well.

Please let me known if someone have found a quicker solution to embed web browser.

If you embed the browser into your code you have not trouble if the browser will update itself in the future and the user have your window container unless the standard browser window.

If you use an external browser you are sure on it well known behaviour but it can be change in the future and if this happens you have to update your application.

I choose to avoid embedded browser and reuse a standard external browser.

Embed http server

I like two solution I have found. All these solution can be use with minimal code change on your web application.

One thing is better you do is to make your web application a Maven application.

To do this in the past I have look at every library in web application class path and put in maven pom.xml dependency tree.

Spring-boot framework

Spring-boot is part of Spring framework.
It is a Spring projects: Spring-boot.
This project help a lot to start your web application.
Since you are developing a web application, you will add a spring-boot- starter-web dependency in maven pom.xml
It standard embed server web is tomcat7/8 but you can change to Jetty8/9 or Undertow 1.1

Spark framework

This framework is a good alternative to Spring-boot. It is more concise and use Jetty as embedded web server.

I like Spring-boot because I am use to Spring configuration and use a mix of xml/annotation configuration and I like spring IoC. Using Spring-boot it easy to add other Spring constellation capability.

I hope that this can help you.

Community
  • 1
  • 1
  • It seems that javacef and jcef is the only one possible live option since JavaFX contains old buggy version of webkit and SWT does not support chromium. I will try to build it, so sad, these projects does not provide binaries. – jreznot Apr 24 '16 at 13:43