Author

Topic: Java JSON server (Read 2278 times)

sr. member
Activity: 322
Merit: 251
August 20, 2012, 05:53:11 PM
#5
Quote
well you need to get GSON, so you create json in java, then you probably want to install tomcat, and then learn to program servlets. Or the hacky way use jetty and you can just extend the server part and just make it return json using GSON

This is pretty standard now, especially since Jetty is very common for HTTP stuff in Android applications, etc. Not just desktop/server applications.
sr. member
Activity: 322
Merit: 251
August 20, 2012, 05:51:17 PM
#4
If you want to just make your jar standalone and not having to have a tomcat server running, as suggested above, you can use the following libraries to accomplish what you're looking for:

http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch18s02.html
http://jetty.codehaus.org/jetty/
hero member
Activity: 574
Merit: 500
August 20, 2012, 06:17:58 AM
#3
Quote
well you need to get GSON, so you create json in java, then you probably want to install tomcat, and then learn to program servlets. Or the hacky way use jetty and you can just extend the server part and just make it return json using GSON

GSON + POJO + JSP = Great.
legendary
Activity: 3598
Merit: 2386
Viva Ut Vivas
August 19, 2012, 08:45:38 PM
#2
Quote
and then learn to program servlets.

Thanks. I think this is where I need to focus first.

I tend to do everything command line so it can be difficult. I set up a tomcat web.xml once by hand and recall that it was a bitch.

But I would rather do it that way and understand what everything is configured to than just letting Eclipse fill everything in for me.
legendary
Activity: 3598
Merit: 2386
Viva Ut Vivas
August 18, 2012, 07:17:07 PM
#1
This is not really a BTC specific question but I am frustrated and ultimately will be using this for BTC.

I am looking for the best way to be able to write a Java server instance that can be called from a website and return JSON strings.

I am running Ubuntu and JDK 1.6.

I have tried a few things I found on the Internet. Jax-ws, JSON-RPC 2.0...

The Jax-ws I tried had a hello world example that I just could not get running. I could run it with the example war in tomcat 7 but when I tried to compile it with the source it just would not work. I got the JSON-RPC Server compiled to get a jar as well as the required JSON-RPC Base but could find absolutely nothing on how I am supposed to install or run it.

All I want is to get to the point of a simple "hello world" where I send a simple string and return "hello world" in JSON format. From there I can expand upon it.

I have worked on the client side with JSON and java apps at work but have not implemented a server.

Any help would be appreciated.
Jump to: