Creating a java library, a place where any problem can be resolved.

Thinking Out Code
2 min readMar 21, 2022

--

Starting with the next class, called SummerDelivery, a delivery service planned to refresh a hot summer day…

But if we running the command to order a PEACH_TENTATION or a FROZEN_APPLE:

The program doesn’t know how to prepare one of its offered beverages, it needs a source with beverages preparation knowledge.

So, having the source below, capable of resolving SummerDelivered needs, called TropicalJuice:

It’s necessary to include it inside SummerDelivery class to attend juice orders.

First of all, we compile TropicalJuice to a class file, executing the command below:

After, we package their .class files generated in a storage called tropical.jar, our java library, running the command below:

With the created tropical.jar, we add to SummerDeliver class the library new methods.

Adding the library in the first executed command:

Yep! Now SummerDelivery knows how to refresh this summer! But it still doesn’t know how to serve a Water glass. If you know how to resolve it, please feel free to add it and test it to practice.

That’s all!

  1. A problem happened.
  2. We create a solution to solve it.
  3. Package the solution as a library.
  4. Add it and test it.
  5. Problem fixed.

Command and options dictionary:

  • java run .class and .java files.
  • javaccompile .java files and creates .class files.
  • -dindicate output folder.
  • -cpindicate compiled folders directory(classpath).
  • jar to execute actions related to java libraries.
  • —create indicate jar action command.
  • —file indicates a name file.

Tech stack

  • Java 11.
  • Windows 10.

Repo

--

--

Thinking Out Code

Software engineer sharing stories & ideas on performant coding development, dev tools’ effective use’s & software development’s life experiences.🧠&♥ involved.