How to create a desktop app for the existing web application? - java

Well, I've tried to do some researches before creating a question but only a little has been found.
Basically, I have got a Spring-based web application. Apparently, you can navigate through web application using HTTP requests and URLs. If you want to edit a user you do a GET request /users/edit/{id} and a new page appears. Then you make some changes to the user and do a POST request /users/edit/{id} and let's say the main page appears.
So, now I need to create a desktop application which can do the same things.
Do I need to rewrite the whole app to port it on the desktop? Is it possible somehow to do sort of HTTP requests from the desktop app to the server, then get a response and process it? Or perhaps there is a proper way to do it?
I feel like it's a big topic but I only need you to point me in the right direction as I'm lacking experience in creating both desktop and web applications together (I'd say, I have never ported app from web to desktop and vice verse).
Earlier I created a few apps using JavaFX and I want to use it again as my GUI platform for the desktop app.

You can go for a solution like, Electron.
It's a framework for creating native applications with web technologies like JavaScript, HTML, and CSS. It uses Chromium and Node.js. You can develop your desktop GUI applications using front and back end components originally developed for your web application.
I'm just pointing you a way. You can look in to this solution and it's also open-source.

If you were about to develop the frontend from scratch I'd recommend you to use something like Ionic Framework where in the latest beta 4 allows you to write once run everywhere (web, PWA, desktop with Electron, and build native build for iOS and Android).
Basically Ionic is an Angular 7 library/superset that allows you to create mobile apps based on a webview. This webview can be embedded and run on any device in a native way.
Even though the same codebase can be run on multiple devices you can customise the look and feel on each platform and access through Cordova, Electron or Capacitor the native device capabilities and hardware.
If you don't want to rewrite the web client, you can use any desktop framework with the preferred language you want. Any modern language/framework will allow you to make HTTP requests against your backend and get the data through your API.
Honestly, nowadays I'd day that JavaFX is not the best option out there and I'd recommend you to go through the web-based approach.
Good luck!

Related

Same Sencha app for web and mobile

Query is : I have a current web application in place to provide me data in a list which is built using java and ui is built using jsp. I want to design a mobile app in Sencha to perform the same task and simultaneously want it in desktop using Sencha/ExtJs.
Now I am confused in following manner :
Do I need to create separate applications for web app and mobile app?
For the web app I need to load a separate set of files whereas for the mobile app it is different. If the application is one then can I do this?
Also, all the java files which I am using for the getting the list data, should be in same code base or separate?
Thanks in advance.
Sencha is a mobile app development framework based on HTML5 and query. So the controls and views are basically designed for mobile screens. But it does not stop you to display the same content on normal desktop browsers. Although what looks great on mobile may not look that good on a browser and vice versa.
Do I need to create separate applications for web app and mobile app?
Not really, everything can be same, views middleware and even backend. If you can design a UI that may look both on mobile and desktop then you are good.
For the web app I need to load a separate set of files whereas for the
mobile app it is different. If the application is one then can I do
this?
As I said above, except UI nothing should be a concern. If you want different look and feel for web and mobile then just create different HTML files for the said purposes. But you can use the same backend logic.
Also, all the java files which I am using for the getting the list
data, should be in same code base or separate?
Generally dynamic web applications fetches the data from backend servers using ajax/http service calls. You may manage the code in a single project or can divide it in logically smaller projects for better management. Maven should be a good choice to manage your projects.

event java google app engine

I just started using google app engine to develop a web application and I'm a little lost on how to deal with events sent from buttons properly.
For some reason, when I try to use a JButton on my application I get this error.
"javax.swing.JButton is not supported by Google App Engine's Java runtime environment"
the only way I managed to get an on_click event so far was to use an html button and use a "post" or "get" requests.
So, is their a tutorial somewhere to help me understand better how to use buttons and other components in my application?
I think you have a deep misunderstanding of what Google AppEngine does. You deploy your code to AppEngine, and it runs on Google's servers. It generally interacts with users in the form of HTTP requests. A user enters a URL, and the Java code might send back some HTML and javascript.
A JButton is a Java Swing component, which is used when developing Java software to run on an end user's machine. Your AppEngine app is not going to run on an end user's machine. You are seeing that error message, because GAE has a whitelist of allowed classes from the JRE.
https://developers.google.com/appengine/docs/java/jrewhitelist
It's possible you may be thinking of Google Web Toolkit(GWT). GWT allows you to write the client/server of a web application in Java, and then cross-compile the client into javascript. This is separate from AppEngine. Although you can develop a GWT application, and deploy it on AppEngine.

How do I connect my Desktop Java Application to an Existing GAE Datastore?

Currently I have a very basic desktop Java application in Eclipse that is meant to add entities to an existing project's datastore on Google App Engine. I have it all setup right now but since I am new to working with Google App Engine, I have no clue on how to get the application to send the Entities into the datastore of my existing project.
I tried looking this up online but most of what I found was for making java web apps. My goal is to have the application running as its own application, not through a browser.
So, what do I have to do to make the application connect to my GAE datastore? Is there some code I need to type, or perhaps some xml file I need to have within the project? I am just using the Java Eclipse plugin for Google App Engine.
Thanks for the help!
Based on the language of your question, I think you really need a big-picture sort of answer, rather than any specific code. Therefore:
You have a desktop application. This runs on some desktop computer.
You have a Google App Engine application with its data store. This runs in Google's data centers.
These are not the same computer. Therefore, they must communicate over the network in some fashion — that is the missing piece you're looking for.
Since GAE is designed around doing web applications, I recommend you think of this as a “web service” situation — that is, your desktop application makes HTTP requests to your GAE application. (The situation is simplified over the general case because you are writing both the client and the server.)
I recommend you read about designing simple web services and do whatever seems to fit your application.
One important warning: Unless your GAE application only ever has one user, you must not simply write a bridge that gives access to the data store over HTTP, because then anyone can make arbitrary changes to other people's data. As it is said for multiplayer game design: don't trust the client — that is, only accept network requests that make sense according to the rules of your application, and do not expect the client to enforce those rules. This is because anyone can make requests to your GAE application using something other than your desktop application, so you must assume you could receive arbitrary requests. This is the fundamental nature of the Internet.
For example, in the simple case of a multi-user application whose users do not interact with each other using the application, this means that every request that, say, updates a record, should only update a record which belongs to the logged-in user, not one of any other user.
For anyone that gets this problem in the future, I got an answer to it. I just tried experimenting around with the project settings and found it. So as it turns out, after you have installed the GAE Eclipse Plugin, you can just right click your project folder in the Package Explorer, go the Google sub menu, then click on App Engine Settings... .
From there, you need to check the Use Google App Engine checkbox, then in the deployment section, just fill in your project's Application ID. Your project's application ID can be found under the Application Settings tab of your project's online Google app engine dashboard. It is listed there as your Application Identifier.
Turns out that for me, I will need to find a different solution as you cannot integrate GAE with a desktop application that uses the Java Swing library. Bummer :/

Web application and mobile application

I want to ask if im using ruby on rails for my web application, what language should I make mobile version(or custom mobile version) of the accordingly my web application?? I need to use JRuby or ?? use Java instead? what is the suggestion that can be combine this two that work together?
Assuming you want to use the classical "HTML mobile web app", the answer is this:
You should ship HTML-only to the users. All communication between the mobile app and the servers should be via an API (JSON is a decent choice for the API protocol, and it's easy to implement in Rails).
You can create the HTML in any way you please - e.g. by compiling .erb/.haml templates in rails.
But on the finished app, you should optimally only have index.html, styles.css and scripts.js.
You can ship an html web app via PhoneGap

Is it possible to bundle my ASP.NET app into a self executable web app? (I know Java can)

NOTE: I'm a veteran Java developer (10yrs) and have recently decided to make things interesting and jump over to the ASP.NET / C# world. Thus the question...
I have a business requirement to build an ASP.NET web application that can be installed into an "enterprise data center" for use by an entire organization or can be downloaded by a single user and run on their desktop (assuming WinXP or higher). Installing the web application into an enterprise environment is easy, but allowing single users to download a file, double-click, then access the application through their web browser is an entirely different story.
To solve the single user dilemma in Java, I would simply bundle the Jetty web app server into my application and configure the WAR file to start up the web server and run the web application when someone double clicks on it.
Is there any way within the .NET world to do something like this?
Are there other .NET web app containers that I could bundle into my application?
Would I need to create an Installer Wizard that would configure IIS on the users machine?
Any help is much appreciated.
probably the closest thing to what you're describing would be a WPF Browser Application.
What I personally would use is a ClickOnce installed winform or wpf application.
You can include the Cassini web server (free to distribute). This server is great for one or two users, but you wouldn't want to run your site on it.
http://www.ultidev.com/products/Cassini/
There's a side benefit to this .... you can include the code in your solution and set break points wherever you need them. If you're using SharpDevelop instead of Visual Studio set Cassini as the startup project.
EDIT : Just checked the site and I'm not sure if it's open source anymore. I may have used Reflector to generate code to set break-points.

Categories

Resources