Bitcoin Forum
May 04, 2024, 08:46:31 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Java JSON server  (Read 2250 times)
Elwar (OP)
Legendary
*
Offline Offline

Activity: 3598
Merit: 2384


Viva Ut Vivas


View Profile WWW
August 19, 2012, 12:17:07 AM
 #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.

First seastead company actually selling sea homes: Ocean Builders https://ocean.builders  Of course we accept bitcoin.
1714812391
Hero Member
*
Offline Offline

Posts: 1714812391

View Profile Personal Message (Offline)

Ignore
1714812391
Reply with quote  #2

1714812391
Report to moderator
1714812391
Hero Member
*
Offline Offline

Posts: 1714812391

View Profile Personal Message (Offline)

Ignore
1714812391
Reply with quote  #2

1714812391
Report to moderator
"Your bitcoin is secured in a way that is physically impossible for others to access, no matter for what reason, no matter how good the excuse, no matter a majority of miners, no matter what." -- Greg Maxwell
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
Elwar (OP)
Legendary
*
Offline Offline

Activity: 3598
Merit: 2384


Viva Ut Vivas


View Profile WWW
August 20, 2012, 01:45:38 AM
 #2

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.

First seastead company actually selling sea homes: Ocean Builders https://ocean.builders  Of course we accept bitcoin.
vampire
Hero Member
*****
Offline Offline

Activity: 574
Merit: 500



View Profile
August 20, 2012, 11:17:58 AM
 #3

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.
nhodges
Sr. Member
****
Offline Offline

Activity: 322
Merit: 251


View Profile
August 20, 2012, 10: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/

nhodges
Sr. Member
****
Offline Offline

Activity: 322
Merit: 251


View Profile
August 20, 2012, 10:53:11 PM
 #5

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.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!