You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/10/29 18:49:32 UTC

[GitHub] nswamy closed pull request #12969: [MXNET-1160] add Java build/run example

nswamy closed pull request #12969: [MXNET-1160] add Java build/run example
URL: https://github.com/apache/incubator-mxnet/pull/12969
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docs/tutorials/scala/mxnet_java_install_and_run_examples.md b/docs/tutorials/scala/mxnet_java_install_and_run_examples.md
new file mode 100644
index 00000000000..83e1ec5b2da
--- /dev/null
+++ b/docs/tutorials/scala/mxnet_java_install_and_run_examples.md
@@ -0,0 +1,123 @@
+# Install and run Java Examples
+
+## Prerequisites:
+Please follow the Step 1 in the [Scala configuration](http://mxnet.incubator.apache.org/install/scala_setup.html#setup-instructions)
+These should help you install the correct Java version and all dependencies.
+
+## Run the Java example project
+We have provided a general MXNet Java template under `scala-package/mxnet-demo/java-demo` which contains the necessary project files for you to get started. It contains a simple Hello world! equivalent program `JavaSample.java` and a full fledged `ObjectDetection.java `that shows how to run Object Detection on images using MXNet and pre-trained SSD model.
+
+Alternatively you could build project from scratch following the below instructions.
+
+## Import and run the Java package
+For users using a desktop/laptop, we recommend using IntelliJ IDE as it is tested and supported to provide the necessary documentation for the Java API.
+
+Alternatively, users can follow the second instruction to set up an empty Maven project for Java.
+
+### IntelliJ instruction
+If you are using a computer with Ubuntu16.04 or Mac, you can install IntelliJ to run the Java package. Please follow the instruction below:
+
+1. Create a new Java project in IntelliJ. Fire up IntelliJ and click `Create New Project`.
+
+2. Click `Next`, and in the `Create project from template` window, do not select anything and click `Next` again.
+
+3. In the next window choose your `Project name` and the `Project location` and click on `Finish`.
+
+4. Let's add the Java Inference API jars that we build from source. At the top of the window, Go to the `File -> Project Structure`. In the popup window that opens up, click on `Libraries -> +` and select the path to the jar files downloaded. Click `Apply` and then click `OK`.
+
+6. Create a new Java class under the folder `your-project-name/src`. Let's call this class `JavaSample.java`. Type in the following code snippet and run it. In this code snippet, we create an NDArray object in Java and print its shape.
+```java
+import org.apache.mxnet.javaapi.Context;
+import org.apache.mxnet.javaapi.NDArray;
+
+public class JavaSample {
+public static void main(String[] args) {
+  System.out.println("Hello");
+  NDArray nd = NDArray.ones(Context.cpu(), new int[] {10, 20});
+
+  System.out.println("Shape of NDarray is : "  + nd.shape());
+}
+}
+```
+
+7. If all went well, you should see an output like this :
+```
+Hello
+SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
+SLF4J: Defaulting to no-operation (NOP) logger implementation
+SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
+Shape of NDarray is : (10,20)
+Process finished with exit code 0
+```
+This means you have successfully set it up on your machine
+
+### Run the project manually in Maven
+In this example, Maven is being used to create the project. This tutorial referred the [Maven in 5 min](https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html) tutorial.
+
+1. Create a new folder and run the following commands
+```
+mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
+```
+You can specify the `groupId` and `artifactId` to your favourite names. You can also create a maven project using empty archetype.
+
+2. then go to `pom.xml` file in your project folder and add the following content.
+
+- Change the `osx-x86_64` to `linux-x86_64` if your platform is linux.
+- Change `cpu` into `gpu` if you are using gpu
+- Change the version of your package from `1.3.1-SNAPSHOT` to the matched jar version.
+```xml
+<dependency>
+  <groupId>org.apache.mxnet</groupId>
+  <artifactId>mxnet-full_2.11-osx-x86_64-cpu</artifactId>
+  <version>1.3.1-SNAPSHOT</version>
+  <scope>system</scope>
+  <systemPath>path-to-your-jar/jarName.jar</systemPath>
+</dependency>
+<dependency>
+  <groupId>args4j</groupId>
+  <artifactId>args4j</artifactId>
+  <version>2.0.29</version>
+  </dependency>
+<dependency>
+  <groupId>org.slf4j</groupId>
+  <artifactId>slf4j-api</artifactId>
+  <version>1.7.7</version>
+</dependency>
+<dependency>
+  <groupId>org.slf4j</groupId>
+  <artifactId>slf4j-log4j12</artifactId>
+  <version>1.7.7</version>
+</dependency>
+```
+3. Finally you can replace the code in `App.java`
+```java
+import org.apache.mxnet.javaapi.Context;
+import org.apache.mxnet.javaapi.NDArray;
+
+public class App {
+public static void main(String[] args) {
+  System.out.println("Hello");
+  NDArray nd = NDArray.ones(Context.cpu(), new int[] {10, 20});
+
+  System.out.println("Shape of NDarray is : "  + nd.shape());
+
+}
+}
+```
+make the package by
+```
+mvn package
+```
+
+and run it by
+```
+java -cp target/my-app-1.0-SNAPSHOT.jar:<full-path-to-jar>/<jarName>.jar com.mycompany.app.App
+```
+The result looks like this:
+```
+Hello
+SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
+SLF4J: Defaulting to no-operation (NOP) logger implementation
+SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
+Shape of NDarray is : (10,20)
+```
\ No newline at end of file
diff --git a/scala-package/mxnet-demo/java-demo/Makefile b/scala-package/mxnet-demo/java-demo/Makefile
new file mode 100644
index 00000000000..340a50f7596
--- /dev/null
+++ b/scala-package/mxnet-demo/java-demo/Makefile
@@ -0,0 +1,54 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+SCALA_VERSION_PROFILE := 2.11
+SCALA_VERSION := 2.11.8
+MXNET_VERSION := 1.3.1-SNAPSHOT
+
+ifeq ($(OS),Windows_NT)
+	UNAME_S := Windows
+else
+	UNAME_S := $(shell uname -s)
+endif
+
+ifeq ($(UNAME_S), Windows)
+	# TODO: currently scala package does not support windows
+	SCALA_PKG_PROFILE := windows
+else
+	ifeq ($(UNAME_S), Darwin)
+		SCALA_PKG_PROFILE := osx-x86_64-cpu
+	else
+		SCALA_PKG_PROFILE := linux-x86_64
+		ifeq ($(USE_CUDA), 1)
+        	SCALA_PKG_PROFILE := $(SCALA_PKG_PROFILE)-gpu
+        else
+        	SCALA_PKG_PROFILE := $(SCALA_PKG_PROFILE)-cpu
+        endif
+	endif
+endif
+
+javademo:
+	(mvn package -Dmxnet.profile=$(SCALA_PKG_PROFILE) \
+		-Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE) \
+		-Dmxnet.version=$(MXNET_VERSION) \
+		-Dscala.version=$(SCALA_VERSION))
+
+javaclean:
+	(mvn clean -Dmxnet.profile=$(SCALA_PKG_PROFILE) \
+		-Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE) \
+		-Dmxnet.version=$(MXNET_VERSION) \
+		-Dscala.version=$(SCALA_VERSION))
\ No newline at end of file
diff --git a/scala-package/mxnet-demo/java-demo/README.md b/scala-package/mxnet-demo/java-demo/README.md
new file mode 100644
index 00000000000..ffe614a2928
--- /dev/null
+++ b/scala-package/mxnet-demo/java-demo/README.md
@@ -0,0 +1,76 @@
+# MXNet Java Sample Project
+This is an project created to use Maven-published Scala/Java package with two Java examples.
+## Setup
+Please copy the downloaded MXNet Java package jar file under the `java-demo` folder.
+
+User are required to use `mvn package` to build the package,
+ which are shown below:
+```Bash
+export SCALA_VERSION_PROFILE=2.11 SCALA_VERSION=2.11.8 MXNET_VERSION=1.3.1-SNAPSHOT
+export SCALA_PKG_PROFILE=
+mvn package -Dmxnet.profile=$(SCALA_PKG_PROFILE) \
+		-Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE) \
+		-Dmxnet.version=$(MXNET_VERSION) \
+		-Dscala.version=$(SCALA_VERSION)
+```
+These environment variable (`SCALA_PKG_PROFILE`, `SCALA_VERSION_PROFILE`, `MXNET_VERSION`, `SCALA_VERSION`)
+should be set before executing the line above.
+ 
+You can also use the `Makefile` as an alternative to do the same thing. Simply do the following:
+```Bash
+make javademo
+```
+This will load the default parameter for all the environment variable.
+ If you want to run with GPU on Linux, just simply add `USE_CUDA=1` when you run the make file
+
+## Run
+### Hello World
+The Scala file is being executed using Java. You can execute the helloWorld example as follows:
+```Bash
+java -cp $CLASSPATH sample.HelloWorld
+```
+However, you have to define the Classpath before you run the demo code. More information can be found in the `demo.sh` And you can run the bash script as follows:
+```Bash
+bash bin/java_sample.sh
+```
+It will load the library automatically and run the example
+### Object Detection using Inference API
+We also provide an example to do object detection, which downloads a ImageNet trained resnet50 model and runs inference on an image to return the classification result as
+```Bash
+Class: car
+Probabilties: 0.99847263
+Coord:312.21335, 72.02908, 456.01443, 150.66176
+Class: bicycle
+Probabilties: 0.9047381
+Coord:155.9581, 149.96365, 383.83694, 418.94516
+Class: dog
+Probabilties: 0.82268167
+Coord:83.82356, 179.14001, 206.63783, 476.78754
+```
+
+you can run using the command shown below:
+```Bash
+java -cp $CLASSPATH sample.ObjectDetection
+```
+or script as follows:
+```Bash
+bash bin/run_od.sh
+```
+
+If you want to test run on GPU, you can set a environment variable as follows:
+```Bash
+export SCALA_TEST_ON_GPU=1
+```
+## Clean up
+Clean up for Maven package is simple, you can run the pre-configed `Makefile` as:
+```Bash
+make javaclean
+```
+
+## Q & A
+If you are facing opencv issue on Ubuntu, please try as follows to install opencv 3.4 (required by 1.2.0 package and above)
+```Bash
+sudo add-apt-repository ppa:timsc/opencv-3.4
+sudo apt-get update
+sudo apt install libopencv-imgcodecs3.4
+```
\ No newline at end of file
diff --git a/scala-package/mxnet-demo/java-demo/bin/java_sample.sh b/scala-package/mxnet-demo/java-demo/bin/java_sample.sh
new file mode 100644
index 00000000000..50e7fb9eb97
--- /dev/null
+++ b/scala-package/mxnet-demo/java-demo/bin/java_sample.sh
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#!/bin/bash
+CURR_DIR=$(cd $(dirname $0)/../; pwd)
+CLASSPATH=$CLASSPATH:$CURR_DIR/target/*:$CLASSPATH:$CURR_DIR/*
+java -Xmx8G  -cp $CLASSPATH sample.HelloWorld
\ No newline at end of file
diff --git a/scala-package/mxnet-demo/java-demo/bin/run_od.sh b/scala-package/mxnet-demo/java-demo/bin/run_od.sh
new file mode 100644
index 00000000000..5cbc53fbcef
--- /dev/null
+++ b/scala-package/mxnet-demo/java-demo/bin/run_od.sh
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#!/bin/bash
+CURR_DIR=$(cd $(dirname $0)/../; pwd)
+
+CLASSPATH=$CLASSPATH:$CURR_DIR/target/*:$CLASSPATH:$CURR_DIR/*
+java -Xmx8G  -cp $CLASSPATH sample.ObjectDetection
\ No newline at end of file
diff --git a/scala-package/mxnet-demo/java-demo/pom.xml b/scala-package/mxnet-demo/java-demo/pom.xml
new file mode 100644
index 00000000000..5014d2e09f5
--- /dev/null
+++ b/scala-package/mxnet-demo/java-demo/pom.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>Demo</groupId>
+    <artifactId>mxnet-java-demo</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <name>MXNet Java Demo</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.mxnet</groupId>
+            <artifactId>mxnet-full_${mxnet.scalaprofile}-${mxnet.profile}</artifactId>
+            <version>${mxnet.version}</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/mxnet-full_${mxnet.scalaprofile}-${mxnet.profile}-${mxnet.version}.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.4</version>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file
diff --git a/scala-package/mxnet-demo/java-demo/src/main/java/sample/HelloWorld.java b/scala-package/mxnet-demo/java-demo/src/main/java/sample/HelloWorld.java
new file mode 100644
index 00000000000..60619dc8a80
--- /dev/null
+++ b/scala-package/mxnet-demo/java-demo/src/main/java/sample/HelloWorld.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package sample;
+
+import org.apache.mxnet.javaapi.*;
+import java.util.Arrays;
+
+public class HelloWorld {
+    public static void main(String[] args) {
+    	System.out.println("Hello World!");
+        NDArray nd = new NDArray(new float[]{2.0f, 3.0f}, new Shape(new int[]{1, 2}), Context.cpu());
+        System.out.println(nd.shape());
+    }
+}
diff --git a/scala-package/mxnet-demo/java-demo/src/main/java/sample/ObjectDetection.java b/scala-package/mxnet-demo/java-demo/src/main/java/sample/ObjectDetection.java
new file mode 100644
index 00000000000..bf9a93ae821
--- /dev/null
+++ b/scala-package/mxnet-demo/java-demo/src/main/java/sample/ObjectDetection.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package sample;
+import org.apache.mxnet.infer.javaapi.ObjectDetectorOutput;
+import org.apache.mxnet.javaapi.*;
+import org.apache.mxnet.infer.javaapi.ObjectDetector;
+import org.apache.commons.io.FileUtils;
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class ObjectDetection {
+    private static String modelPath;
+    private static String imagePath;
+
+    private static void downloadUrl(String url, String filePath) {
+        File tmpFile = new File(filePath);
+        if (!tmpFile.exists()) {
+            try {
+                FileUtils.copyURLToFile(new URL(url), tmpFile);
+            } catch (Exception exception) {
+                System.err.println(exception);
+            }
+        }
+    }
+
+    public static void downloadModelImage() {
+        String tempDirPath = System.getProperty("java.io.tmpdir");
+        System.out.println("tempDirPath: %s".format(tempDirPath));
+        imagePath = tempDirPath + "/inputImages/resnetssd/dog-ssd.jpg";
+        String imgURL = "https://s3.amazonaws.com/model-server/inputs/dog-ssd.jpg";
+        downloadUrl(imgURL, imagePath);
+        modelPath = tempDirPath + "resnetssd/resnet50_ssd_model";
+        System.out.println("Download model files, this can take a while...");
+        String modelURL = "https://s3.amazonaws.com/model-server/models/resnet50_ssd/";
+        downloadUrl(modelURL + "resnet50_ssd_model-symbol.json",
+                tempDirPath + "/resnetssd/resnet50_ssd_model-symbol.json");
+        downloadUrl(modelURL + "resnet50_ssd_model-0000.params",
+                tempDirPath + "/resnetssd/resnet50_ssd_model-0000.params");
+        downloadUrl(modelURL + "synset.txt",
+                tempDirPath + "/resnetssd/synset.txt");
+    }
+
+    static List<List<ObjectDetectorOutput>>
+    runObjectDetectionSingle(String modelPathPrefix, String inputImagePath, List<Context> context) {
+        Shape inputShape = new Shape(new int[] {1, 3, 512, 512});
+        List<DataDesc> inputDescriptors = new ArrayList<DataDesc>();
+        inputDescriptors.add(new DataDesc("data", inputShape, DType.Float32(), "NCHW"));
+        ObjectDetector objDet = new ObjectDetector(modelPathPrefix, inputDescriptors, context, 0);
+        return objDet.imageObjectDetect(ObjectDetector.loadImageFromFile(inputImagePath), 3);
+    }
+
+    public static void main(String[] args) {
+        List<Context> context = new ArrayList<Context>();
+        if (System.getenv().containsKey("SCALA_TEST_ON_GPU") &&
+                Integer.valueOf(System.getenv("SCALA_TEST_ON_GPU")) == 1) {
+            context.add(Context.gpu());
+        } else {
+            context.add(Context.cpu());
+        }
+        downloadModelImage();
+        Shape inputShape = new Shape(new int[] {1, 3, 512, 512});
+        Shape outputShape = new Shape(new int[] {1, 6132, 6});
+        int width = inputShape.get(2);
+        int height = inputShape.get(3);
+        List<List<ObjectDetectorOutput>> output
+                = runObjectDetectionSingle(modelPath, imagePath, context);
+        String outputStr = "\n";
+        for (List<ObjectDetectorOutput> ele : output) {
+            for (ObjectDetectorOutput i : ele) {
+                outputStr += "Class: " + i.getClassName() + "\n";
+                outputStr += "Probabilties: " + i.getProbability() + "\n";
+
+                List<Float> coord = Arrays.asList(i.getXMin() * width,
+                        i.getXMax() * height, i.getYMin() * width, i.getYMax() * height);
+                StringBuilder sb = new StringBuilder();
+                for (float c: coord) {
+                    sb.append(", ").append(c);
+                }
+                outputStr += "Coord:" + sb.substring(2)+ "\n";
+            }
+        }
+        System.out.println(outputStr);
+    }
+}
\ No newline at end of file
diff --git a/scala-package/mxnet-demo/Makefile b/scala-package/mxnet-demo/scala-demo/Makefile
similarity index 96%
rename from scala-package/mxnet-demo/Makefile
rename to scala-package/mxnet-demo/scala-demo/Makefile
index 227697ba2e8..458077d1390 100644
--- a/scala-package/mxnet-demo/Makefile
+++ b/scala-package/mxnet-demo/scala-demo/Makefile
@@ -17,7 +17,7 @@
 
 SCALA_VERSION_PROFILE := 2.11
 SCALA_VERSION := 2.11.8
-MXNET_VERSION := 1.2.0
+MXNET_VERSION := 1.3.0
 
 ifeq ($(OS),Windows_NT)
 	UNAME_S := Windows
diff --git a/scala-package/mxnet-demo/README.md b/scala-package/mxnet-demo/scala-demo/README.md
similarity index 88%
rename from scala-package/mxnet-demo/README.md
rename to scala-package/mxnet-demo/scala-demo/README.md
index e30a61a2fc1..300fc7b2e10 100644
--- a/scala-package/mxnet-demo/README.md
+++ b/scala-package/mxnet-demo/scala-demo/README.md
@@ -4,7 +4,7 @@ This is an project created to use Maven-published Scala package with two Scala e
 User are required to use `mvn package` to build the package,
  which are shown below:
 ```Bash
-export SCALA_VERSION_PROFILE=2.11 SCALA_VERSION=2.11.8 MXNET_VERSION=1.2.0
+export SCALA_VERSION_PROFILE=2.11 SCALA_VERSION=2.11.8 MXNET_VERSION=1.3.0
 export SCALA_PKG_PROFILE=
 mvn package -Dmxnet.profile=$(SCALA_PKG_PROFILE) \
 		-Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE) \
@@ -12,7 +12,9 @@ mvn package -Dmxnet.profile=$(SCALA_PKG_PROFILE) \
 		-Dscala.version=$(SCALA_VERSION)
 ```
 These environment variable (`SCALA_PKG_PROFILE`, `SCALA_VERSION_PROFILE`, `MXNET_VERSION`, `SCALA_VERSION`)
-should be set before executing the line above. 
+should be set before executing the line above.
+
+To obtain the most recent MXNet version, please click [here](https://mvnrepository.com/search?q=org.apache.mxnet)
  
 You can also use the `Makefile` as an alternative to do the same thing. Simply do the following:
 ```Bash
@@ -25,7 +27,7 @@ This will load the default parameter for all the environment variable.
 ### Hello World
 The Scala file is being executed using Java. You can execute the helloWorld example as follows:
 ```Bash
-java -Xmx8G  -cp $CLASSPATH sample.HelloWorld
+java -cp $CLASSPATH sample.HelloWorld
 ```
 However, you have to define the Classpath before you run the demo code. More information can be found in the `demo.sh` And you can run the bash script as follows:
 ```Bash
@@ -41,7 +43,7 @@ You can review the complete example [here](https://github.com/apache/incubator-m
 
 you can run using the command shown below:
 ```Bash
-java -Xmx8G  -cp $CLASSPATH sample.ImageClassificationExample
+java -cp $CLASSPATH sample.ImageClassificationExample
 ```
 or script as follows:
 ```Bash
@@ -59,7 +61,7 @@ make scalaclean
 ```
 
 ## Q & A
-If you are facing opencv issue on Ubuntu, please try as follows to install opencv 3.4 (required by 1.2.0 package)
+If you are facing opencv issue on Ubuntu, please try as follows to install opencv 3.4 (required by 1.2.0 package and above)
 ```Bash
 sudo add-apt-repository ppa:timsc/opencv-3.4
 sudo apt-get update
diff --git a/scala-package/mxnet-demo/bin/demo.sh b/scala-package/mxnet-demo/scala-demo/bin/demo.sh
similarity index 100%
rename from scala-package/mxnet-demo/bin/demo.sh
rename to scala-package/mxnet-demo/scala-demo/bin/demo.sh
diff --git a/scala-package/mxnet-demo/bin/run_im.sh b/scala-package/mxnet-demo/scala-demo/bin/run_im.sh
similarity index 100%
rename from scala-package/mxnet-demo/bin/run_im.sh
rename to scala-package/mxnet-demo/scala-demo/bin/run_im.sh
diff --git a/scala-package/mxnet-demo/pom.xml b/scala-package/mxnet-demo/scala-demo/pom.xml
similarity index 100%
rename from scala-package/mxnet-demo/pom.xml
rename to scala-package/mxnet-demo/scala-demo/pom.xml
diff --git a/scala-package/mxnet-demo/src/main/scala/sample/HelloWorld.scala b/scala-package/mxnet-demo/scala-demo/src/main/scala/sample/HelloWorld.scala
similarity index 100%
rename from scala-package/mxnet-demo/src/main/scala/sample/HelloWorld.scala
rename to scala-package/mxnet-demo/scala-demo/src/main/scala/sample/HelloWorld.scala
diff --git a/scala-package/mxnet-demo/src/main/scala/sample/ImageClassificationExample.scala b/scala-package/mxnet-demo/scala-demo/src/main/scala/sample/ImageClassificationExample.scala
similarity index 100%
rename from scala-package/mxnet-demo/src/main/scala/sample/ImageClassificationExample.scala
rename to scala-package/mxnet-demo/scala-demo/src/main/scala/sample/ImageClassificationExample.scala
diff --git a/tests/tutorials/test_sanity_tutorials.py b/tests/tutorials/test_sanity_tutorials.py
index cd3f6bfcbac..078e96b3b29 100644
--- a/tests/tutorials/test_sanity_tutorials.py
+++ b/tests/tutorials/test_sanity_tutorials.py
@@ -49,6 +49,7 @@
              'scala/mnist.md',
              'scala/index.md',
              'scala/mxnet_scala_on_intellij.md',
+             'scala/mxnet_java_install_and_run_examples.md',
              'sparse/index.md',
              'speech_recognition/index.md',
              'unsupervised_learning/index.md',


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services