<?php require_once( dirname(dirname(dirname( __FILE__ ))) . '/wp-load.php' ); ?>
<!-- START of header -->
<?php get_header(); ?>
<!-- END of header -->

<!-- warapper -->

<div class="docs-content">
<!-- START of page navigation -->
<?php get_template_part( 'docs_navigation' ); ?>
<!-- END of page navigation -->
<!-- START of pusher -->
<div class="docs-content-body">
<div id="content" class="docs-content-body__inner">

        
<h1 class="title">5.1.4 Preparation: Environment (client)</h1>
<h2 id="overview">Overview</h2>
<p>This chapter shows the procedure to build an environment where you can build and execute GridDB Java applications. These instructions are specifically use Windows 10 (64 bit) as a development environment and CentOS 7.2 (64 bit) as an execution environment but can be adapted for other operating systems as well. <br/></p>
<br>

<h2 id="obtaining-the-files">Obtaining the files</h2>
<p>First download the following the files to your build environment, the tested versions and filenames are listed in Table 1.</p>

<p><strong>Table 1 file available to</strong></p>
<div class="griddb" markdown="1">

</div>
<table style="width:90%;" class="table-dl-connector">
<colgroup>
<col style="width: 16%" />
<col style="width: 15%" />
<col style="width: 13%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Software</th>
<th style="text-align: center;">Version</th>
<th style="text-align: left;">File name</th>
<th style="text-align: left;">Site to get</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Java(Java SE Development Kit) (Windows)</td>
<td style="text-align: center;">8u102</td>
<td style="text-align: left;">jdk-8u101-windows-x64.exe</td>
<td style="text-align: left;"><a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">Java SE Development Kit 8</a></td>
</tr>
<tr class="even">
<td style="text-align: left;">Java(Java SE Development Kit) (Linux)</td>
<td style="text-align: center;">8u102</td>
<td style="text-align: left;">jdk-8u101-linux-x64.rpm</td>
<td style="text-align: left;"><a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">Java SE Development Kit 8</a></td>
</tr>
<tr class="odd">
<td style="text-align: left;">Eclipse(Eclipse IDE for Java Developers)</td>
<td style="text-align: center;">Neon</td>
<td style="text-align: left;">eclipse-java-neon-R-win32-x86_64.zip</td>
<td style="text-align: left;"><a href="http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/neonr">Eclipse IDE for Java Developers</a></td>
</tr>
</tbody>
</table>


<h2 id="construction-of-build-environment">Construction of Build Environment</h2>
<h3 id="java-installation">Java Installation</h3>
<p>Table 1 there run the Java installer (jdk-8u102-windows-x64.exe), and install it. If you do not want to change the setting, it will be installed in <code>C:\ Program Files \ Java \ jdk1.8.0_102</code>.</p>
<br>

<h3 id="setting-of-environment-variable">Setting of environment variable</h3>
<p>First set Java's path in the Windows environment variable registry. <br />
<code> Control Panel &gt; system and security &gt; system &gt; Advanced System Settings and click </code>, <code>Open the properties</code> of the system.</p>
<p><img class="center" src="img/prepare_client_01.png" alt="Figure 1 System Advanced" title="Figure 1 System Advanced Settings" style="border: 1px # 999999 solid; width: 500px;"> </img> <br/> <span style="text-align: left"> <strong>Figure 1 system Advanced </strong></span></p>
<p>Click on the <code>Advanced tab</code> of <code>environment variable (N) ...</code> button.</p>
<p><img class="center" src="img/prepare_client_02.png" alt="Figure 2 environment variable" title="Figure 2 environment variable" style="width: 400px;"> </img> <br/> <span style="text-align: left"> <strong>Figure 2 environment variable </strong></span></p>
<p>Add the following to the environment variable to the system environment variables:</p>
<ul>
<li>Variable name: <code>JAVA_HOME</code></li>
<li>Variable value: <code>C:\Program Files\Java\jdk1.8.0_102</code></li>
</ul>
<p><img class="center" src="img/prepare_client_03.png" alt="Figure 3 Java environment variable" title="Figure 3 Java environment variables" style="width: 500px;"> </img> <br/> <span style="text-align: left"> <strong>Figure 3 Java environment variable </strong></span></p>
<p>In addition, the system path must be changed by first selecting 'Path' in the list, clicking the 'Edit' button, and then then inserting &quot;%JAVA_HOME%;&quot; to the beginning of the text field.</p>
<p><img class="center" src="img/prepare_client_04.png" alt="Figure 4 Edit Path" title="Figure 4 Edit Path" style="width: 500px;"> </img> <br/> <span style="text-align: left"> <strong>Figure 4 Edit Path </strong></span></p>
<p>After you change the above environment variables click the 'OK' button.</p>
<p><br/></p>
<h3 id="install-eclipse">Install Eclipse</h3>
<p>Follow Eclipse's instructions on how to run the Eclipse. No specific options are required for GridDB development.</p>
<p><br/></p>
<h3 id="import-of-source-code">Import of source code</h3>
<p>After Eclipse is installed you can start it and create a workspace in any location.</p>
<p>Download the source code for the first GridDB sample presented in GridDB Basics <a href="https://www.griddb.net/en/docs/documents/img/griddb-first.zip">here: griddb_first.zip</a>.</p>
<p><img class="center" src="img/prepare_client_05.png" alt="Figure 5 Creating a work space" title="Figure 5 Creating a work space" style="width: 500px;"> </img> <br/> <span style="text-align: left"> <strong>Figure 5 Creatde a Workspace </strong></span></p>
<p>In the Eclipse Package Exploer click the 'Import' function:</p>
<p><img class="center" src="img/prepare_client_06.png" alt="6 project import of" title="6 project import of"> </img> <br/> <span style="text-align: left"> <strong>6 project import of </strong></span></p>
<p>Select <code> General &gt; Existing Projects </code> and click the <code>Next</code> button.</p>
<p><img class="center" src="img/prepare_client_07.png" alt="7 import method selection" title="7 import method selection" style="width: 400px;"> </img> <br/> <span style="text-align: left"> <strong>7 import method selection </strong></span></p>
<p>Select the Zip file that you downloaded and click the <code>Finish</code> button.</p>
<p><img class="center" src="img/prepare_client_08.png" alt="Figure 8 import method selection" title="8 import method selection" style="width: 400px;"> </img> <br/> <span style="text-align: left"> <strong>8 import method selection </strong></span></p>
<h3 id="build-of-jar-file">Build of jar file</h3>
<p>Use the Ant build.xml that will compile and generates a jar file.</p>
<p>In the Package Explorer <code> build &gt; to select build.xml </code> to display the context menu, Click on the <code>1 Ant Build Run As &gt;</code>.
<p><img class="center" src="img/prepare_client_09.png" alt="9 build run" title="9 build run" style="width: 700px;"> </img> <br/> <span style="text-align: left"> <strong>9 build run </strong></span></p>
<p>If the build is successful, jar file in the folder out is output. When you click the <code>Refresh</code> in the context menu of the Package Explorer, It shows.</p>
<p><img class="center" src="img/prepare_client_10.png" alt="Figure 10 build success" title="Figure 10 build success" style="width: 700px;"> </img> <br/> <span style="text-align: left"> <strong>Figure 10 build success </strong></span> <br/></p>
<h2 id="construction-of-execution-environment">Construction of execution environment</h2>
<p>Then, in gshost that you created in the Environment (server)] (../ sample_app_prepare_server) Install the Java in order to run the sample application.</p>
<br>
<h3 id="installation-of-java">Installation of Java</h3>
<p>Place Table 1 of Java of rpm files (jdk-8u101-linux-x64.rpm) to any location on the gshost, Please install the following procedure.</p>
<pre class="prettyprint linenums">
$ cd /tmp
$ sudo rpm -Uvh /tmp/jdk-8u101-linux-x64.rpm
$ sudo alternatives --config java

There are 2 programs which provide 'java'.

  Selection Command
-----------------------------------------------
* + 1 /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.111-2.6.7.2.el7_2.x86_64/jre/bin/java
   2 /usr/java/jdk1.8.0_102/jre/bin/java

Press Enter to keep the current selection [+], or type the selection number you wish too use. In this case, we want to use <strong> 2 </strong>. Now java returns corresponds with the correct version.

$ java -version
java version "1.8.0_102"
Java (TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot (TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
</pre>
<p><br/></p>
<h3 id="placement-of-the-jar-file">Placement of the jar file</h3>
<p>Create a sample directory and copy the files from the built Eclipse project as follows:</p>
<pre class="prettyprint linenums">
sample /
├─lib ... Directly copy the lib directory of the Eclipse project.
│ gridstore-conf.jar
│ gridstore.jar
│ opencsv-3.8.jar
├─data ... Directly copy the data directory in the Eclipse project.
│ liveimage1.jpg
│ liveimage2.jpg
│ instrument_log.csv
│ weather_station.csv
└─ &lt; jar file &gt; ... Copy the jar file from the output directory of the Eclipse project.
</pre>
You can run the sample application as follows:
<pre>
<p>$ java -jar &lt; jar file &gt;</p></pre>
</div>
</div>
</div>
</div>
</div>
<!-- / main -->

<?php get_footer(); ?>
