We are going to create a java standalone Desktop application. We are searching for the best solution for the presentation layer. I saw javaFX and really liked it, but I am a bit confused. Can it be used in standalone Desktop applications?
Can I use javaFX in my standalone Desktop app and also use css to style the Ui?
It is perfectly possible to use JavaFX in a standalone Desktop app and apply CSS styling to it.
In JavaFX's lingo, this is know as a "Standalone" or "Self-Contained" deployment.
You can even integrate it with Swing or SWT, if the need arises. Note, though, that it's not possible the other way round.
Related
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:
Use embedded web browser (e.g. Chrome) as GUI toolkit for Java desktop applications?
Is it possible to create Desktop Application using Java backend & Web Technologies UI
Performance of WebView in JavaFX
Integrating JavaFX 2.0 WebView into a Swing Java SE 6 Application
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.
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:
jcef on github.com
build instructions
jcef on bitbucket.org
build instructions
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.
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:
Is it possible to have a single code base for a desktop GUI and a
web application?
Run Jetty Web Server Within Your Application
Running a web application (WAR) with embedded jetty server
I'm planning to develop a web based drawing tool using the java backend, what my question is can I use swing as a front end for this application or do I need to go for html canvas kind of technology.
Anyway my preference is to develop the front end using swing but need to know whether is it possible for a web based application.
Web based usually means that it's available on a website. Swing is not a website. You could use Java Webstart to launch a Swing application, but I wouldn't call that "web based".
Then of course you have applets, but I'd advise against that, since many people have disabled the Java plugin for security reasons.
I need a integrated or embedded java browser. I used WebEngine of javafx which support basic css as well html & java script but could not able to run flash file. Any way to do so.
Or any other Project u know which could fulfill my requirement.
You can also look at JxBrowser Java library that allows embedding Chromium-based web browser control into Java AWT/Swing application.
It supports both Java Swing and JavaFX.
BTW: the browser control is totally lightweight. All rendering happens in a separate native process by native Chromium engine. The web page looks like it's displayed in Google Chrome.
Check those (although they are not JavaFX but I suppose that they can be used):
http://lobobrowser.org/java-browser.jsp - pure Java
http://www.javadesktop.org/articles/jdic/index.html - better imho, but no longer maintained
What's out there that lets you do this? Are there any OSS projects or maybe something a little more popular than this: http://www.jpackages.com/jflashplayer/ ? This does exactly what I'm suggesting (i.e. cuts out the need for Swing UI for the most part) but for a number of reasons I'd be interested in any better alternatives. Are there any? Any alternatives would need to support the Flex SDK.
Use the SWT GUI toolkit, which has an embedded browser. You can even deploy you own webkit with it, and let flash run in this browser, so you are platform independent, and don't rely on native browsers.
It will however be a large deployment, because of the browsers size.
EDIT: You can also emed the Flash ActiveX control directly in an SWT composite (Composite is the JPanel of SWT)
JavaFX 2 has a web control. I can't remember if the beta can do flash yet or if still upcoming. But if it doesn't support flash yet then it probably will soon, they release updates every 2 or so weeks to test.
You could also try the JFlashPlayer from DJ Native Swing: http://djproject.sourceforge.net/ns
It is essentially the SWT Browser, but with all sorts of integration headaches solved, and proper API.
I recently played around with the SWT browser widget (which is great). I am wondering if I could write a full desktop application with it (with java services behind - e.g. persistence) and what drawbacks I would have to consider. The advantage would be that people without java knowledge could work on the gui. Of course it depends on the requirements and I know that this is not a very specific question. But mabye someone already tried to build a bigger app this way and is willing to share insights.
Thanks
Marcel
I'm not sure I share your opinion of the SWT browser widget. AFAIK it's merely a shell into the default browser on your machine, merely with a few API access points. I've used it for minor things when I needed to show a web page from within the application. But writing a whole application? That doesn't make sense.
If you want to build a web-based application that runs in the browser against a Java based server framework, there are many AJAXian frameworks to do it. You'd still be doing JavaScript for your client code. And you'd still be dealing with all the complexities of different browsers. I'm not sure why you would want to host it inside an SWT application instead of just directly in the browser window.