I am trying to make a little game in java and it needs to ask a server to verify it's data.
I'd like to use heroku because I want to write the server in ruby with sinatra but I don't really know a good way to get websockets working with java.
My last bet is just to use normal sockets within ruby but because of the way heroku does it's port routing normal socket apps don't really work.
The answer to this question here makes it sound like there is a way I can do it using http requests.
Is there a way to do that or am I running around in circles?
Related
im working on a simple app in flutter and i think im overthinking. What is the best and most efficient way to make dart communicate with java?
I've seen people using http requests but I don't have a server that can respond to http requests.
So I'm trying to use the system with the MethodChannel but I can't get the code to work as intended.
Are there better systems besides this one? Are there any guides or example app you can recommend for using these systems?
I have started java not that long ago, and I was wondering, if I want to make a GUI, and then I want the gui to display some data, I can't have mysql connection in that gui, it's a very big security exploit, therefore I've thought about making a java server that receives packets, and sends back data.
I know PHP HTTP callbacks are the best for this, but I really want to get into the server/networking in java.
Is there any library that offers such thing? Tutorials?
Use Grizzly, Mina, or Netty. Here's Sun's sockets tutorial if you want to learn from the ground up. Grizzly and Mina use Java NIO which is confusing to a beginner. Might want to start with the tutorial.
Out of the 3 frameworks I suggested, I've only used Netty for a project. I read Netty was lower level, and had more speed 6 months ago. It worked well for me.
I'm writing a web server by Java. This server is just to use socket to get the connection from client, parse the request and call the corresponding handler to handle this request. But I want to make a page using Django. However, I don't know how to run python script when the server get the request, and Django site tell me that it can be used in Apache by wsgi, so I guess I can do it as well, but how to implement it?
To get a good idea of what is WSGI you can read the official documentation (PEP-333). But basically WSGI is a big hash table that you pass to your WSGI application.
Since you are writing your server with Java an important part of your project will be to figure out how to call python code from inside your Java code.
But if you avoid writing this Java web server, you can tale a look at other tools that will give give your a better support to run your python WSGI app.
Apache with mod_wsgi
Mongrel2 with wsgid
Nginx with gunicorn
Good luck!
It is a bit confusing as to what you are really after. If you want to run Python WSGI applications, including Django on a Java server, then look at Jython and modjy.
http://opensource.xhaus.com/projects/show/modjy
I was wondering if it's possible to send commands from a website to a java program being ran on a computer.
Basically what I'm doing is creating a robot, but I want control over it when I'm away from my computer. So what I was thinking, was that if I could send it commands (Like 'Stop' or 'Start') from a website, I could use my smartphone to control it.
If you know a way that might work or another method that's similar please let me know, thanks!
What I've done in the past is built the Java robot into a Java EE webapp, then deployed the webapp on Tomcat. Tomcat is a Java-based web server. It's a web server, but there's also no reason you can't run arbitrary code inside it, like a robot.
Another alternative is to embed a web server into the robot, and have the robot serve up pages itself. An example of an embedded HTTP server is JETTY.
Using the above two approaches, the web pages and Robot can communicate with each other directly through Java code. It's a single process and a single JVM running both.
A third alternative is to connect the Java robot process with the web server process via sockets or another form of IPC. This could be tricky, but decouples nicely.
one starting point is:
RPC the wikipedia article will guide you through other options and names that can help you. If it is really that basic. Socket Programming is the right way.
I was wondering if it's possible to send commands from a website to a
java program being ran on a computer.
This equivalent to asking if 2 programs can communicate via network.
The answer is yes. It is obvious, right? I mean how do you connect to your website in the first place? Eh?
I really don't know what I'm doing, and have been trying to learn about it, but I figured I would ask for help; I have a java server (essentially the one here: http://www.akira.ruc.dk/~keld/teaching/OOP_f02/Book/chap09/BroadcastEchoServer.java, just playing around with stuff so I can learn about it), and I want to be able to run it on the internet , so with the client applet I wrote that you can embed in a browser, say, you can connect to it from different computers. I really have no idea how to go about it. I downloaded some things (Tomcat, Glassfish), signed up for google app engine, and something I think is similar specifically for Java, but I'm not really sure what I am doing. I am thinking I get j2ee or something? I use a mac and xcode, if that's useful at all.
Thanks in advance
Oh, the client applet is like the one from a java socket tutorial here:
java.sun.com/docs/books/tutorial/networking/sockets/readingWriting.html
If your server is already working locally, what you need to do is to put it in a hosting service.
That way it can be accessible by everyone else.
That server, is an stand alone application ( that is, it doesn't need tomcat or glassfish, and certainly won't run on Google App Engine )
The only thing you need to do, is have it install it in a machine which is accessible from the internet. How to host an application is out of the scope of this site though.