1、下载redis java 客户端
https://github.com/xetorthio/jedis/downloads
jedis-2.1.0.jar
2、编写代码
package org.soachina.redis;
import redis.clients.jedis.Jedis;
public class Demo {
public static void main(String args[]){
Jedis test = new Jedis("127.0.0.1",6379);
test.set("hw","hello world");
String hello = test.get("hw");
System.out.println(hello);
}
}
3、在centos 6上运行
把上面的代码打包为 redis.jar,并把jedis-2.1.0.jar放在同一目录下
java -Djava.ext.dirs=. -jar redis.jar
>>hello world
<EOF>