Code Monkey home page Code Monkey logo

weather-cli's Introduction

Weather Service Application

Description

This Java application allows users to fetch and display the current weather information for a specified city and country. It uses the OpenWeatherMap API to retrieve weather data and displays it in a user-friendly format.

Features

  • Fetches real-time weather data from the OpenWeatherMap API.
  • Displays weather information such as temperature, humidity, pressure, wind speed, and a description of the weather.
  • Provides an interactive console interface for user input.

Requirements

  • Java 11 or higher
  • Gson library
  • OkHttp library
  • An API key from OpenWeatherMap

Installation

  1. Clone the repository:

    git clone https://github.com/gabrielalmir/weather-cli.git
    cd weather-service
  2. Add the required libraries to your project. If you are using Maven, add the following dependencies to your pom.xml:

    <dependencies>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>4.9.3</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.8</version>
        </dependency>
    </dependencies>
  3. Set up your OpenWeatherMap API key as an environment variable:

    export OPENWEATHER_API_KEY=your_api_key_here

Usage

  1. Compile the application:

    javac -cp .:path_to_gson.jar:path_to_okhttp.jar br/com/gabrielalmir/*.java
  2. Run the application:

    java -cp .:path_to_gson.jar:path_to_okhttp.jar br.com.gabrielalmir.Main
  3. Follow the on-screen prompts to enter a city and country code to get the weather information.

Example

Please enter your city: 
London
Please enter your country code: (e.g. US, UK, IN, BR)
UK
Looking for weather of London - UK
Weather{name='London', description='clear sky', temperature=15.0, humidity=72, pressure=1012, wind=3.6}
Do you want to check another city? (y/n) 
n
Goodbye! ๐Ÿ˜Š

weather-cli's People

Contributors

gabrielalmir avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.