Java Folder Structure In Our Month Of Java

in #java8 years ago

Into Week Two And We Are "Hopefully" Getting Serious About Our Java

background-code-coder-177598.jpg
Image Courtesy of pexels.com

The first time around I was looking at learning Java for creating Android apps and was really confused with folder and directory structure. Fast forward to, officially the third time I have tried to learn Java, and I thought I would get this part out of the way early. Looking at the documentation, its pretty simply how things are set up to keep all our Java classes and packages in an organized state.

What Did I Learn Today


How should we be setting up our folder structure in our Java Applications: Usually the first line in the Java code will indicate which class is in what package. In the small pieces of code we have been working on so far we have not been adding this statement because our code is simply part of an unnamed default package. The names of the nested packages are divided by periods(.), almost like a URL.
The package name relates to the directory structure which the class resides in and you must store a Java class in a directory with a relative directory path that matches the package name for that class.

For example we could add the package statement at the start of our Java class:

 1 package classes.animals;
 2 public class Cat {
 3  // rest of code
  • In the above code the package statement shows that the Cat class is part of the classes.animals package
  • For the Java runtime to find the Cat class, we must then store this class as a file named Cat.java in the directory structure classes/animals
  • The JVM class loader finds the class by appending the relative path name to each directory that you specify in the classpath
  • The JVM can also find the class by searching for ZIP files and JAR files that you specify in the class path

I also found a list of applications and projects that are running Java(In case you were interested)

  • Minecraft, the most popular survival sandbox game in the world, was written by Marcus 'Notch' Persson and, yes, he used Java.
  • Google+ (the entire server side) and many other Google services.
  • The best development tools, such as Eclipse and IntelliJ IDEA (you’ll find out more about IDEA a little bit later).
  • Facebook web app for Android… And almost every other Android app you use.
  • Amazon web services. Yes, as you make your Amazon purchases, you're using Java. Can you imagine?
  • The majority of Netflix services are built on Java. Remember that as you watch your favorite show.
  • The Android operating system is written in Java (user interface) together with C and C++.
  • Lots of Tesla Motors applications are built in Java.

I'll be posting daily, sharing my experiences on my “1 Month of Java Code” experiences”, my previous post on day 7 can be found below, so feel free to have a look:
https://steemit.com/java/@run.vince.run/more-new-stuff-for-day-7-of-my-month-of-java

If you have found this post useful or interesting, please consider Commenting, Upvoting, Following and/or Resteeming

Sort:  

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by run.vince.run from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

Coin Marketplace

STEEM 0.04
TRX 0.33
JST 0.099
BTC 64125.80
ETH 1796.79
USDT 1.00
SBD 0.38