Javafx web client with a server - java

I have to make a final project (Software Engineering) which should be on web (I chose javafx over HTML5). The project's purpose is to learn people typing blindly. The user gets a sentence and he should rewrite it. The application should save all the information of users so that is why I need a server.
I have got some questions:
Can I use simple java socket server with javafx?
If the answer is yes, are there web hosting services that support simple socket server? I heard something about tomcat or something like this. If the answer is no, what other choices do I have?
What is the best plugin for eclipse to work with javafx? I mean, I need a designer.
Another thing that I need from the server is to send sound files to the client, which type of java server allows it?

Can I use simple java socket server with javafx?
Yes. It's a Java application, after all, and you can open a socket (client or server).
If the answer is yes, are there web hosting services that support simple socket server? I heard something about tomcat or something like this. If the answer is no, what other choices do I have?
You should not focus on this. Instead, try to create a set of (REST) services. Your application in the server side (Jetty, Tomcat or whatever) will be the producer and your Java FX application will be a consumer of these services.
What is the best plugin for eclipse to work with javafx? I mean, I need a designer.
This is off topic because it falls into personal preference. I don't know about such a designer. And IMO I prefer to design in my head and just write the code I come up with that.
Another thing that I need from the server is to send sound files to the client, which type of java server allows it?
A sound file is a file, after all, and a file is just a byte[] that will be sent through the net. Learn how to handle this when creating/consuming your services.

Related

JSF web application to monitor client resources

I have to provide a way in which a server will monitor its client's resources (i.e. cpu usage and ram) and store the data in a database.
I am learning about the JSF right now and aim to develop a web application that will use OperatingSystemMXBean methods on the client to get the resources of that machine. The problem is that I am not sure if this is the right approach to the task or even possible to do it with the JSF - operatingSystemMXBean combo.
My question - is it possible to do it this way? And if yes, is this approach worth the effort or is there a far simpler way of doing it.
Thank you.
You can not run java code on the client side. As you are new to JSF you should read more about this technology. The java codes that you write in jsf pages compile in the server side and the result will pass to client browser. If you want to get client resources like ram and cpu you need third party apps on the client side. Maybe there were some plugins that installs on client browser to do this(or you write your own) that you should search more about this. And also another approach is that you write a program which installs in the client pc to send his resources information to your server over internet.

How to implement a socket for a Java EE application in Tomcat

I've a Python application for data analysis and a Java EE application for web monitoring. Now I need to establish a durable communication between them, in order to transfer the analysis result from python to java.
Since both of the applications are located at the same server, I want to implement a TCP socket. As for the data volume, there're about 10 sensors' data transferred per second. I'm using Tomcat 8.0 for Java EE and a simple script for python. So my questions are :
Is socket implementation a good idea ?
If yes, how to implement it, can somebody give me a tutorial or example ?
If not, what should I do next ?
Additional information
I saw a related question on StackOverflow How to serve a socket from a Java EE application, there're some propositions :
Implement a Connector (JCA). But I think the target runtime is JBoss rather than Tomcat.
Implement a Java Naming and Directory Interface (JNDI). That's what I'm trying as you can see as my previous question Why JNDI resource can only be called once in Tomcat? People use JNDI for using resources, e.g. db connection. So I'm not sure if it's a good way for realtime communication. And I've met many troubles by learning it.
I thought about web-socket. But does it mean I need a python server as well ?
I believe there is a hundred way to do it to share data between these technologies. But for Java you should keep it simple. In Tomcat you don't need to write a socket implementation, you just need a basic Servlet implementation. So basically for your questions.
Is socket implementation a good idea ?
Shortly NO.
If yes, how to implement it, can somebody give me a tutorial or
example ?
Already answered NO.
If not, what should I do next ?
Write a basic servlet application who listen an server url address. Your phyton script is just a client. In phyton site you just send a POST request to servlet url and in Java side get the request read your data and process it. You can start to learn Servlet from Mkyong.

Copy files from multiple remote servers using JAVA

I need some advice and some suggestions on which approach to follow to create my application.
Objective :
Copy log files from around 14 to 16 remote servers to a client application, which would be used for monitoring purposes.
I know I can write a Multi-threaded or thread-pooled server-client application in java, but would that be feasible?
Or if there is a way that allows the java client application to log-in to the server and copy files from it all by itself, just as we use 'SCP'.
(Is it even possible?)
Or if there is a much better of handling such issues.
Which approach would be better and why?
Edit:
I want to copy files from a remote server, and the question is that whether should I use a client-server socket program to do so, or a library such as JSch?
Maybe you can consider my advise. I once programmed it the other way around. Copying files to one central file server. The program was installed on several servers.
This was implemented with Spring Integration. I've created a message channel with an outbound ftp channel adapter. This setup did the job with little implementation and configuration.
I know Spring Integration for FTP is also using JSCH under the hood.

What is the best way to create a client-server application with a Java Web Start program?

Ok so I have created an application, which is a Java Web Start application, but I have determined that I will need to write data to the server machine, hence the need for an additional server application. Pretty much I want the client to send different strings in order to process a clients requests in varying ways (eg create a new user file on the server machine or send user data read from a file to the client machine).
I was thinking of possibly using sockets, but if there is a better way then I'm all for that. Also I assume that whatever I do use, I will need to use threading in order to process many simultaneous requests, is this correct?
For your purpose you better create a webservice which communicates over http for exchanging data. I would recommend doing this in Java or maybe creating a WCF in C#.
Tutorials in Eclipse for java webservice: http://www.vogella.com/articles/REST/article.html#first_project
In netbeans: http://netbeans.org/kb/docs/websvc/jax-ws.html
The first tutorial is a restful service which is pretty popular and easy to grasp.
Good luck!

How to allow interaction between Java application and user front Web interface

I need to create a user facing web interface (perhaps with HTML5 and Javascript) that allows a user to draw lines using a mouse. The interaction would involve mouse drag, clicks, etc. I need to send these inputs to a Java application on a remote machine and get back some result and update the web page the user's drawing on. So this would require a two way communication.
Since this is a proof of concept prototype, I need a solution that's easy and simple, and hopefully fast since the user would like to see the update quickly. What technology do you recommend to allow the communication between the web interface and java application? I was thinking about writing a simple server in Java and talk to the remote application using JMS... not sure this is the right direction.
Thank you for your insights.
Any servlet container, such as Tomcat, JBoss, Jetty, GlassFish or WebSphere would do.
I'm not sure JMS is a good fit here.
The browser would communicate with the server the way all web-apps do, via http requests. So, on the server you would use servlets, or some frameworks that builds on top of servlets, running in the container of your choice. You webapp would periodically send an xml http request (XHR/AJAX) to update the state of the drawing. Or it would do it when the user wanted to save their design.
Keep in mind what you are describing is a Web Application. This means that an application is running in the browser, so it can maintain its own state independent of the server. It just needs to sync up every now and again. You don't need to continuously send requests to the server.
it can be done also using RIA: actionscript3/flash+xml socket+java server. You can handle events via actionscript3 and then send parameters to server and after receive answer. There is lot of source for as3 drawing api after you can modify for socket connection.
have you tried this ? Look at the demo section on the shared canvas.
http://jwebsocket.org/

Categories