This is a simple example of RMI and OpenWeatherMap API
- Sign up at OpenWeatherMap and get your API key.
- Select your city id at the file list_id_cities.txt (last edition was 5.04.2019)
- Modify these rows at the OpenWeatherMap.java file.
private String API_KEY = "YOUR_API_KEY";
private String CITY_ID = "YOUR_CITY_ID";
- Change or leave row for an accepted unit at the OpenWeatherMap.java file.
- imperial: Temperature in Fahrenheit
private String UNITS = "imperial";
- metric: Temperature in Celsius
private String UNITS = "metric";
Important! You need to have Java JDK! If you don`t have download it
First, you need to run commands for WeatherServer and only after that for WeatherClient
open cmd
make cd to_your_folder
make cd to_src_folder
and run this WeatherServer commands
set "path=%path%;C:\Program Files\Java\jdk1.8.0_201\bin"
javac -classpath "json.jar"; Weather.java
javac -classpath "json.jar"; WeatherData.java
javac -classpath "json.jar"; OpenWeatherMap.java
javac -classpath "json.jar"; WeatherServer.java
javac -classpath "json.jar"; WeatherClient.java
start rmiregistry
java -classpath "json.jar"; WeatherServer
java -classpath "json.jar"; WeatherClient
after that open another cmd and run WeatherClient commands
java -classpath "json.jar"; WeatherClient
PAUSE
open terminal
make cd to_your_folder
make cd to_src_folder
run WeatherServer commands
javac -cp .:json.jar Weather.java
javac -cp .:json.jar WeatherData.java
javac -cp .:json.jar OpenWeatherMap.java
javac -cp .:json.jar WeatherServer.java
javac -cp .:json.jar WeatherClient.java
rmiregistry &
java -cp .:json.jar WeatherServer
java -cp .:json.jar WeatherClient
after that open another terminal window and run WeatherClient command
java -cp .:json.jar WeatherClient