Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Java exercises to Runtime 100.4.0 #152

Merged
merged 1 commit into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 44 additions & 8 deletions runtime-workshop/exercises/Java/Exercise 1 Map and Scene.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This exercise walks you through the following:
- Add a 3D scene to the app, and use a toggle button to switch between 2D and 3D

Prerequisites:
- Install the Java Development Kit (JDK) version 8 or higher.
- Install the Java Development Kit (JDK) version 11 or higher.
- Optional: install a Java integrated development environment (IDE).

If you need some help, you can refer to [the solution to this exercise](../../solutions/Java/Ex1_MapAndScene), available in this repository.
Expand All @@ -26,6 +26,16 @@ If you need some help, you can refer to [the solution to this exercise](../../so
}
```

**Note:** In recent Java releases, the JDK no longer includes JavaFX, so you will probably need to add a JavaFX dependency to your new project. In Maven, this is done as follows inside `pom.xml`'s `<dependencies>` element (which you should create if it does not yet exist):

```
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.1</version>
</dependency>
```

1. Instantiate a field of type `AnchorPane` that will hold the app's UI components:

```
Expand Down Expand Up @@ -75,14 +85,30 @@ If you need some help, you can refer to [the solution to this exercise](../../so
launch(args);
}
```


1. In newer versions of Java, you will probably get the following error if you run the app right now:

>Error: JavaFX runtime components are missing, and are required to run this application

Solve this error by creating a new class with a `main` method and having it call your app class's `main` method, and run this new class instead of your app class ([more info](https://stackoverflow.com/a/52654791/720773)):

```
public class Launcher {

public static void main(String[] args) {
WorkshopApp.main(args);
}

}
```

1. Compile and run your app. Verify that a button appears in the lower-right corner of the app:

![Blank app with button](01-blank-app-with-button.png)

## Add ArcGIS Runtime to the app

You have three options for adding ArcGIS Runtime 100.2.1 to your Java application project. Choose one of the following:
You have three options for adding ArcGIS Runtime to your Java application project. Choose one of the following:

1. **Use Gradle**: you can use Gradle if you started the exercise by creating a Gradle project. Open `build.gradle` and add ArcGIS dependencies. See [Develop your first map app with Gradle](https://developers.arcgis.com/java/latest/guide/develop-your-first-map-app-with-gradle.htm) for details.

Expand All @@ -96,7 +122,7 @@ You have three options for adding ArcGIS Runtime 100.2.1 to your Java applicatio
dependencies { classpath 'com.esri.arcgisruntime:gradle-arcgis-java-plugin:1.0.0' }
}

arcgis.version = '100.2.1'
arcgis.version = '100.4.0'

// download javadoc
eclipse.classpath.downloadJavadoc = true
Expand All @@ -123,8 +149,18 @@ You have three options for adding ArcGIS Runtime 100.2.1 to your Java applicatio
<dependency>
<groupId>com.esri.arcgisruntime</groupId>
<artifactId>arcgis-java</artifactId>
<version>100.2.1</version>
<version>100.4.0</version>
</dependency>
<!-- Add an execution element to have ArcGIS Runtime
automatically downloaded during the compile phase. -->
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>arcgis</goal>
</goals>
</execution>
</executions>
</dependencies>

<build>
Expand All @@ -134,16 +170,16 @@ You have three options for adding ArcGIS Runtime 100.2.1 to your Java applicatio
<artifactId>arcgis-java-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<version>100.2.1</version>
<version>100.4.0</version>
</configuration>
</plugin>
</plugins>
</build>
```

**Note:** Maven downloads the ArcGIS Runtime install to `<user home>/.arcgis`. ArcGIS Runtime tries to find it there, but that can fail under certain conditions. If it fails, you can go inside that install directory and copy the `jniLibs` and `resources` directories to your app's working directory.
**Note:** Maven downloads the ArcGIS Runtime install to `<user home>/.arcgis`. ArcGIS Runtime tries to find it there, but that can fail under certain conditions, especially with older ArcGIS Runtime releases. If it fails, you can go inside that install directory and copy the `jniLibs` and `resources` directories to your app's working directory.

3. **Use the downloaded ArcGIS Runtime SDK**: download the ArcGIS Runtime SDK (version 100.2.1) for Java and unzip it. In your Java project, reference the JAR files in the SDK's `libs` directory. You must also copy the SDK's `jniLibs` and `resources` directories to your Java project directory. (There are other ways of referencing ArcGIS Runtime, but copying `jniLibs` and `resources` is the simplest.) See [Develop your first map app using the downloaded SDK](https://developers.arcgis.com/java/latest/guide/develop-your-first-map-app.htm) for details.
3. **Use the downloaded ArcGIS Runtime SDK**: download the ArcGIS Runtime SDK for Java and unzip it. In your Java project, reference the JAR files in the SDK's `libs` directory. You must also copy the SDK's `jniLibs` and `resources` directories to your Java project directory. (There are other ways of referencing ArcGIS Runtime, but copying `jniLibs` and `resources` is the simplest.) See [Develop your first map app using the downloaded SDK](https://developers.arcgis.com/java/latest/guide/develop-your-first-map-app.htm) for details.

## Add a 2D map to the app

Expand Down
58 changes: 45 additions & 13 deletions runtime-workshop/solutions/Java/Ex1_MapAndScene/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.esri.wdc.geodev</groupId>
<artifactId>Ex1_MapAndScene</artifactId>
<version>2018.04</version>

<version>2019.01</version>
<name>Exercise 1: Map and Scene</name>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<mainClass>com.esri.wdc.geodev.Launcher</mainClass>
</properties>

<repositories>
<repository>
<id>arcgis</id>
Expand All @@ -19,10 +26,15 @@
</pluginRepositories>

<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.1</version>
</dependency>
<dependency>
<groupId>com.esri.arcgisruntime</groupId>
<artifactId>arcgis-java</artifactId>
<version>100.2.1</version>
<version>100.4.0</version>
</dependency>
</dependencies>

Expand All @@ -34,13 +46,21 @@
<artifactId>arcgis-java-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<version>100.2.1</version>
<version>100.4.0</version>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>arcgis</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
Expand All @@ -65,13 +85,13 @@
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<version>3.1.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>dependency/</classpathPrefix>
<mainClass>com.esri.wdc.geodev.WorkshopApp</mainClass>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
</configuration>
Expand All @@ -80,7 +100,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.1</version>
<executions>
<execution>
<goals>
Expand All @@ -89,10 +109,22 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>${mainClass}</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.esri.wdc.geodev;

public class Launcher {

public static void main(String[] args) {
WorkshopApp.main(args);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import javafx.stage.Stage;

/**
* This Application class demonstrates key features of ArcGIS Runtime 100.0.
* This Application class demonstrates key features of ArcGIS Runtime.
*/
public class WorkshopApp extends Application {

Expand Down
58 changes: 45 additions & 13 deletions runtime-workshop/solutions/Java/Ex2_ZoomButtons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.esri.wdc.geodev</groupId>
<artifactId>Ex2_ZoomButtons</artifactId>
<version>2018.04</version>

<version>2019.01</version>
<name>Exercise 2: Zoom Buttons</name>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<mainClass>com.esri.wdc.geodev.Launcher</mainClass>
</properties>

<repositories>
<repository>
<id>arcgis</id>
Expand All @@ -19,10 +26,15 @@
</pluginRepositories>

<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.1</version>
</dependency>
<dependency>
<groupId>com.esri.arcgisruntime</groupId>
<artifactId>arcgis-java</artifactId>
<version>100.2.1</version>
<version>100.4.0</version>
</dependency>
</dependencies>

Expand All @@ -34,13 +46,21 @@
<artifactId>arcgis-java-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<version>100.2.1</version>
<version>100.4.0</version>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>arcgis</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
Expand All @@ -65,13 +85,13 @@
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<version>3.1.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>dependency/</classpathPrefix>
<mainClass>com.esri.wdc.geodev.WorkshopApp</mainClass>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
</configuration>
Expand All @@ -80,7 +100,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.1</version>
<executions>
<execution>
<goals>
Expand All @@ -89,10 +109,22 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>${mainClass}</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.esri.wdc.geodev;

public class Launcher {

public static void main(String[] args) {
WorkshopApp.main(args);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import javafx.stage.Stage;

/**
* This Application class demonstrates key features of ArcGIS Runtime 100.0.
* This Application class demonstrates key features of ArcGIS Runtime.
*/
public class WorkshopApp extends Application {

Expand Down
Loading