diff --git a/BUILDING.md b/BUILDING.md index 308ef8a9e5c3..1086bdd47013 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -10,12 +10,13 @@ Set the JAVA\_HOME environment variable. For example: | OSX | ``export JAVA_HOME=`/usr/libexec/java_home -v 1.8`` | | Windows | ``set JAVA_HOME="C:\Program Files\Java\jdk1.8.0_121"`` | -Download the project source from the Releases page at [Apache Geode] -(http://geode.apache.org/releases/), and unpack the source code. +Download the project source from the Releases page at +[Apache Geode](http://geode.apache.org/releases/), and unpack the source code. Within the directory containing the unpacked source code, run the gradle build: - - $ ./gradlew build +```console +$ ./gradlew build +``` Once the build completes, the project files will be installed at `geode-assembly/build/install/apache-geode`. The distribution archives will be @@ -23,8 +24,9 @@ created in `geode-assembly/build/distributions/`. Verify the installation by invoking the `gfsh` shell command to print version information: - - $ ./geode-assembly/build/install/apache-geode/bin/gfsh version - v1.1.0 +```console +$ ./geode-assembly/build/install/apache-geode/bin/gfsh version +v1.1.0 +``` Note: on Windows invoke the `gfsh.bat` script to print the version string. diff --git a/README.md b/README.md index b9d94bdc7d25..54b9686ffd0d 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ can load dependencies from [Maven Central](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.apache.geode%22). Maven -``` +```xml org.apache.geode @@ -57,7 +57,7 @@ Maven ``` Gradle -``` +```groovy dependencies { compile "org.apache.geode:geode-core:$VERSION" } @@ -117,69 +117,76 @@ instructions on how to build the project. Geode requires installation of JDK version 1.8. After installing Apache Geode, start a locator and server: - - $ gfsh - gfsh> start locator - gfsh> start server +```console +$ gfsh +gfsh> start locator +gfsh> start server +``` Create a region: - - gfsh> create region --name=hello --type=REPLICATE +```console +gfsh> create region --name=hello --type=REPLICATE +``` Write a client application (this example uses a [Gradle](https://gradle.org) build script): _build.gradle_ +```groovy +apply plugin: 'java' +apply plugin: 'application' - apply plugin: 'java' - apply plugin: 'application' - - mainClassName = 'HelloWorld' +mainClassName = 'HelloWorld' - repositories { mavenCentral() } - dependencies { - compile 'org.apache.geode:geode-core:1.4.0' - runtime 'org.slf4j:slf4j-log4j12:1.7.24' - } +repositories { mavenCentral() } +dependencies { + compile 'org.apache.geode:geode-core:1.4.0' + runtime 'org.slf4j:slf4j-log4j12:1.7.24' +} +``` _src/main/java/HelloWorld.java_ - - import java.util.Map; - import org.apache.geode.cache.Region; - import org.apache.geode.cache.client.*; - - public class HelloWorld { - public static void main(String[] args) throws Exception { - ClientCache cache = new ClientCacheFactory() - .addPoolLocator("localhost", 10334) - .create(); - Region region = cache - .createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY) - .create("hello"); - - region.put("1", "Hello"); - region.put("2", "World"); - - for (Map.Entry entry : region.entrySet()) { - System.out.format("key = %s, value = %s\n", entry.getKey(), entry.getValue()); - } - cache.close(); - } +```java +import java.util.Map; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.client.*; + +public class HelloWorld { + public static void main(String[] args) throws Exception { + ClientCache cache = new ClientCacheFactory() + .addPoolLocator("localhost", 10334) + .create(); + Region region = cache + .createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY) + .create("hello"); + + region.put("1", "Hello"); + region.put("2", "World"); + + for (Map.Entry entry : region.entrySet()) { + System.out.format("key = %s, value = %s\n", entry.getKey(), entry.getValue()); } + cache.close(); + } +} +``` Build and run the `HelloWorld` example: - - $ gradle run +```console +$ gradle run +``` The application will connect to the running cluster, create a local cache, put some data in the cache, and print the cached data to the console: - - key = 1, value = Hello - key = 2, value = World +```console +key = 1, value = Hello +key = 2, value = World +``` Finally, shutdown the Geode server and locator: - - $ gfsh> shutdown --include-locators=true +```console +gfsh> shutdown --include-locators=true +``` For more information see the [Geode Examples](https://github.com/apache/geode-examples) repository or the