THRIFT-890. java: Fix tutorial to build and run in trunk
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1001856 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tutorial/java/JavaClient b/tutorial/java/JavaClient
index 68d87b8..77b6a05 100755
--- a/tutorial/java/JavaClient
+++ b/tutorial/java/JavaClient
@@ -18,5 +18,8 @@
# specific language governing permissions and limitations
# under the License.
#
+THIS_DIR=$(dirname $0)
+LIB_DIR=$THIS_DIR/../../lib/java/
+IVY_DIR=$LIB_DIR/build/ivy/lib/
-java -cp tutorial.jar:/usr/local/lib/libthrift.jar JavaClient
+java -cp $IVY_DIR/*:$LIB_DIR/libthrift.jar:tutorial.jar JavaClient
diff --git a/tutorial/java/JavaServer b/tutorial/java/JavaServer
index 8961600..3ff9fd8 100755
--- a/tutorial/java/JavaServer
+++ b/tutorial/java/JavaServer
@@ -18,5 +18,8 @@
# specific language governing permissions and limitations
# under the License.
#
+THIS_DIR=$(dirname $0)
+LIB_DIR=$THIS_DIR/../../lib/java/
+IVY_DIR=$LIB_DIR/build/ivy/lib/
-java -cp tutorial.jar:/usr/local/lib/libthrift.jar JavaServer
+java -cp $IVY_DIR/*:$LIB_DIR/libthrift.jar:tutorial.jar JavaServer
diff --git a/tutorial/java/build.xml b/tutorial/java/build.xml
index 0ec1ea4..e7d5c8b 100644
--- a/tutorial/java/build.xml
+++ b/tutorial/java/build.xml
@@ -23,7 +23,17 @@
<property name="src" location="src" />
<property name="gen" location="../gen-java" />
<property name="build" location="build" />
- <property name="cpath" location="/usr/local/lib/libthrift.jar" />
+
+ <path id="libs.classpath">
+ <pathelement path="../../lib/java/libthrift.jar" />
+ <fileset dir="../../lib/java/build/ivy/lib">
+ <include name="*.jar" />
+ </fileset>
+ </path>
+ <path id="build.classpath">
+ <path refid="libs.classpath" />
+ <pathelement path="${gen}" />
+ </path>
<target name="init">
<tstamp />
@@ -31,8 +41,8 @@
</target>
<target name="compile" depends="init">
- <javac srcdir="${gen}" destdir="${build}" classpath="${cpath}" />
- <javac srcdir="${src}" destdir="${build}" classpath="${cpath}:${gen}" />
+ <javac srcdir="${gen}" destdir="${build}" classpathref="libs.classpath" />
+ <javac srcdir="${src}" destdir="${build}" classpathref="build.classpath" />
</target>
<target name="tutorial" depends="compile">
diff --git a/tutorial/java/src/JavaServer.java b/tutorial/java/src/JavaServer.java
index 14440eb..da84c32 100644
--- a/tutorial/java/src/JavaServer.java
+++ b/tutorial/java/src/JavaServer.java
@@ -54,19 +54,19 @@
System.out.println("calculate(" + logid + ", {" + work.op + "," + work.num1 + "," + work.num2 + "})");
int val = 0;
switch (work.op) {
- case Operation.ADD:
+ case ADD:
val = work.num1 + work.num2;
break;
- case Operation.SUBTRACT:
+ case SUBTRACT:
val = work.num1 - work.num2;
break;
- case Operation.MULTIPLY:
+ case MULTIPLY:
val = work.num1 * work.num2;
break;
- case Operation.DIVIDE:
+ case DIVIDE:
if (work.num2 == 0) {
InvalidOperation io = new InvalidOperation();
- io.what = work.op;
+ io.what = work.op.getValue();
io.why = "Cannot divide by 0";
throw io;
}
@@ -74,7 +74,7 @@
break;
default:
InvalidOperation io = new InvalidOperation();
- io.what = work.op;
+ io.what = work.op.getValue();
io.why = "Unknown operation";
throw io;
}
diff --git a/tutorial/tutorial.thrift b/tutorial/tutorial.thrift
index 86e433d..3ea496c 100644
--- a/tutorial/tutorial.thrift
+++ b/tutorial/tutorial.thrift
@@ -66,7 +66,6 @@
namespace java tutorial
namespace php tutorial
namespace perl tutorial
-namespace smalltalk.category Thrift.Tutorial
/**
* Thrift lets you do typedefs to get pretty names for your types. Standard