A Jar is really just a Zip file with some added Metadata (i.e. data about data). They are organized much the same way file systems are organized, think folders nested in folders with importable Java classes being the files in those folders. So if you have a folder hierarchy like edu/redwoods/cis12 and you had several Java files in the cis12 subfolder named Class1 and Class2 you could Zip it up into a .jar file, import it into your IntelliJ project, and then import those classes like so:
import edu.redwoods.cis12.Class1;
import edu.redwoods.cis12.Class1;
This is a slight over-simplification because you would also have to include a package directive at the top of your Java classes, and you should add additional package metadata, but the comparison is pretty close to reality.
- Watch the below linked video, and follow along on how we build a Java Archive artifact (jar) from a GitHub project.
- If you didn't already, attempt to build the artifact/jar file while watching the video, try to build the jar file yourself now!
- Watch the below linked video, and follow along to import an external jar file into your project!
- If your artifact build/creation step was successful, see if you can import your build of the metadata jar file into Java-Assignment-003 after you start PART 2 below!
Just like you do every week now!!!
- Fork my assignment repo
- Use IntelliJ to clone your fork locally
- Use IntelliJ to create a local feature branch
- Complete the following assignment:
Your assignment is to use Built-In java classes to:
- Import the following java Built-In classes from the java.nio and java.util packages respectively.
-
java.nio.file.Paths; java.util.Scanner; java.nio.file.Path;
-
- Read a jpg file path from the user.
- HINT 1: Create a Scanner object instance and use it to read a string.
- HINT 2: Use Paths class to get a path from your input!
- Google java.nio.file.Paths for help OR Look for examples HERE
- From your path object call a method that converts the file path to a File type object (Cause that's what the provided getHiddenSecret method declares as its parameters).
- Pass the file object as an argument to the given getHiddenSecrets method.
- Run the program and type in the path for our sample image, and record the GPS coordinates in the output.
- HINT: the path can be relative to the project directory, maybe use the string in the example above :-)
- Look up the latitude and longitude coordinates in any online map you can find via Google.
- Screenshot the map and add it into the images folder of this project.
- Last add image markdown below this line to load your map image (Hint: Example image Markdown is just a couple lines above this).
- Look at the getHiddenSecrets method and identify the following parts by editing this README.md and providing your answers:
- What is the access modifer (e.g. public, private, protected)?
- Is it a Class method or an object Instance method, how do you know?
- What is its return data-type?
- Does it require any arguments to call it, and if so, how many parameters and of what data-type?
- Scan line by line through the code and try to determine how it works?
- What is familiar to you?
- What is not familiar to you?
- Do the for loops make sense, and if so, tell me what you think they do?
- When completed, use your IDE to Commit and Push your feature branch back to your GitHub Account's fork of Java-Assignment-003.
- From your GitHub account's feature branch, issue a New Pull request from your feature branch to the instructor's fork
- Save the Pull Request URL to submit to your Canvas assignment.