I'm attempting to write a browser based MMO using libGDX and it's HTML5/GWT port and I have no idea how to do the client/server interactions. I have already written the application for desktop as a sort of "learning" project for myself, and have now decided to rewrite it into the browser.
I have never done browser development before, so I'm not quite sure of how to go about doing the networking portion of the project. I fear that this is because I'm not quite sure as to how GWT actually works, especially when being used for what I'm doing. I attempted to use a library called KryoNet for the networking but apparently you cannot use normal networking methods for GWT. I received this error: http://pastebin.com/DVJPA44N
In short, I need help/direction with how to do a client/server communications type deal with GWT if it's even possible. If there is an easy google answer I apologize, I'm not sure how to word what I'm looking for.
Thank you!
EDIT: I looked at the WebSockets API, and that's not quite what I'm looking for. I want to host a server locally off the desktop and communicate to the client hosted in the browser. I apologize if I'm just misunderstanding the whole servlet setup in GWT.
Did you have look at something like PlayN ( Angry Birds is top example using it with GWT for Browser port of the application )
Also you need to checkout WebSocket API ( either direct use in GWT/JSNI or via third-party gwt jar )
Related
As node.js still lacks important functionality which exists in Java, I would like to use Java instead of node.js, and create the client using a web language (html, js, css..).
Electron is cross platform and so does java so it seems fit to have a solution getting the best of both worlds.
Does someone know of a way to integrate electron with java or have a different solution to the problem?
I made something similar, Java back-end with Electron GUI.
You can do it in more ways, it depends on what you need.
You can create a jar file and then execute it like terminal:
https://nodejs.org/api/child_process.html
Or you can open a socket communication and talk on a Port. (A lot of documentation:
Java (web)socket - Node.js client.io)
In this second way, you can do everything you want, but you have to create your communication protocol.
Your path is not foolish, I am very satisfied of the communication and usage in my work with Java + Electron .
I've created a small PoC where Java process is integrated with Electron front-end: https://github.com/jreznot/electron-java-app There you will find a simple TODO List application built with Vaadin/Jetty and Electron.
Personally i made my back-end java communicate with the front-end by creating a file with te data then sending it to the main.js to be processed.
DBus and winDbus seems to be an option here.
It creates nice abstraction and separation between "frontend" and backend
https://sourceforge.net/projects/windbus/
I'm going to test it on my own soon
Can I write client side java in intelliJ, and then simply put it on a server for it to run on a server? Or will I need to write in a specialised version of Java and need to use a specialised IDE instead?
I'm trying to make an app and run the primary functions on a server then have the app send requests and fetch the data from the server. (It will esentially be a search engine of sorts and queries will be made to the server, which will then apply filters and use my algorithms to perform a search, before returning a result to the mobile device). But I'm not sure if I can begin writing this java on intellij, just as I would when making say, a simple calculator, or if I would need to write the java using a specialised server variation and server IDE.
Thank you.
The Java language is the same no matter what, so your logic can be ported easily. However on a server you may use a framework that's different from one you'd use on a client (for example you tagged this android- there wouldn't be Activities or Views on a server. You'd use another framework instead, possibly Spring.) Or you could go frameworkless, but then you'll have to write a lot of code that the frameworks do for you.
As for IDE- an IDE is an editor. You can write Java in notepad if you want. There's no difference, its just what features make your life easier. And yes, IntelliJ is a common choice.
If you would like make your own website, you should go with JavaEE or better with Spring.
If you would like to make simple server side application which will listen on specific port then respond something, go with Sockets
Netty is interesting NIO Socket library
I tried to understand this several times allready, but still have not found out how this should be done.
I want to create a web interface for some existing console or swing application. Something like the web interface SABNzb offers (I know, it's Python – it's just an example).
I have looked at several technologies allready, like creating web services using a tomcat server, or java server pages/faces, but all the tutorials that I found so far start with "Create a new Web Project..." at wich point I stop because this is not what I want! I have a finished an application in which I want to integrate a web interface, not some web service that instantiates my program as a local variable and uses its code. So basicaly it feels like all the tutorials I find are the wrong way around.
The core procedure of this is clear, the application should listen for http requests on a port I choose and answer with a created html code to it. So basicaly I could open a port using a socket and write an html page to its output on connect. But this rather feels like inventing the wheel all over again, also I'm not sure how an interactive web page would work this way.
Maybe I am thinking somewhat strange here or did not understand how some of these things work, but I am pretty unexperienced with web technologies, so grasping the concept is rather hard at the moment. Can anyone point me to a tutorial that shows how this might be done, or some other source of information on it?
You don't need JSP or JSF; all you need is a servlet. It's an HTTP listener class. You can do REST with that.
The moment you say that you have to deploy your servlet in a WAR on a servlet/JSP engine. Tomcat is a good choice.
Google for a servlet tutorial and you'll be on your way.
My First Tomcat Servlet
Ok, thanks to duffymos answer and comments i realized i was actualy searching with the wrong keywords.
Embedded web server is the thing i was looking for.
Like Simple or build in HTTPServer class in java.
First sorry for my english. I am currently trying to develop a JAVA webservice for Android devices. More precisely, the webservice provider would be an ordinary computer and webservices clients would be Android devices.
After I have read some tutorials, I have done this one (webservice + client), which require only Eclipse. Everything works OK. So my question is the following: given that my webservice is working well and is accessible, why would I use soap engine and application server, as mentionned in this short introduction to webservice ? Said another way, what are the advantages, concretely?
I have tried to google, read and learn more, but I am stuck at this point.. If I have well-understood, SOAP engines, like Apache AXIS, allow to dynamically generate SOAP data and to receive requests from different clients. But does not my webservice already generate automatically SOAP requests/responses, since I can use my webservice with my dedicated client?
Regarding application server, I just can't figure out what it is. I found few documentation about that I could understand.
I know that instead of asking these kind of question, a better way would be to practice myself soap engine and application server, but I would prefer to know what I am doing and using rather than to go in a "random mode".
I hope I've been clear, thanks a lot for you answers.
MCFarah
You asked a couple of questions which are quite heavy, but i'll try to give a brief overview:
Web/Application Servers are basically a piece of program that implements a lot of stuff that help the developer, by allowing him to focus on the actual development and not on the stuff around. Stuff like: Threads, security, Database connection pooling etc.
You don't have to use SOAP webservice, actually I think you'd be better off using REST.
The tutorial you did is a "Hello World" tutorial. It is only good for getting started but once you start writing a larger application you would want to use a web server. Id recommend starting with Tomcat.
Just start using the technologies and post questions as you go.
So i have been looking into GWT and it does look pretty interesting as i do have experience in programming in java and being able to create webapps does look very interesting to me.
I have looked at some of the basic tutorials and have got GWT working in my eclipse environment. Now, If i was to begin creating webapps with it how would i go about uploading and hosting my app. I have only used PHP and MySQL for web development so i would always just use Apache, I am not to sure about GWT hosting. Does it require the app to be hosted on googles App Engine platform or can I setup a server like to usually do when using Apache?
Thanks.
Using GWT does not require you to host your app on App Engine. You can host a GWT app on any host.
If you want your server to be written in Java, to take advantage of some of the more useful features of GWT, you will obviously need to find a host that allows you to run Java. But you can write a GWT app that communicates with a PHP server, or a Python server, or anything else.
If you're familiar with PHP + MySQL it's not a bad idea to stick to that and just add your compiled GWT output as another component that you upload. Switching to App Engine requires a fundamental change in the way you write and design your application which means you'll be learning new front-end and back-end technologies at the same time. Just as an example, a simple full-text search on one field is pretty trivial for a small php + mysql app but because App Engine forces you to write extremely scalable code it's not trivial on GAE.