Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Local Development Environments How it Works The Java Virtual Machine

Kevin Faust
Kevin Faust
15,353 Points

question on why we're compiling differently

(updated)

hi

clear && javac com/teamtreehouse/Systemizer.java && java com.teamtreehouse.Systemizer

i dont get why we we couldnt just use clear && javac Systemizer.java && java Systemizer like we always did. whats the difference between the two? we never used the first one before

im wondering why System.getProperty("java.class.path") returns a period? I believe that java.class.path is where all your java files are located on your system (was able to see this after analyzing the code some more on the ide). so therefore since we are just using a workspace, there really isnt a path where the java jdk is installed and thats why it's just a period. correct me if im wrong.

so getProperties() returns all the properties of the current system and has a key and value like a map. both the keys and values are strings. however they're something called a Property object. can someone explain on that some more?

stringPropertyName() basically takes the key values and puts them into a set as strings. is this usually used in conjunction with System.getProperties()?

and in the video we did a bit of changing directories. we used cd/tmp to switch but again, whats a reason for switching out of our default directory. do we often do this?

im still wondering what the point is of doing all this. Its cool to see how we can see all the properties of our system, but im just not sure how this would be incorporated in a project of some sort. what can we actually do and achieve with these properties?

thanks

1 Answer

Hello,

When the console is in the same directory that the file is within, System.getProperty("java.class.path") returns a period, the console is in (home/treehouse/workspace) initially, so there's a period because it is in fact in the same directory. However, to compile you need to enter com/teamtreehouse/Systemizer.java because the file is that not in the root of (home/treehouse/workspace), but folders within it. and run java com.teamtreehouse.Systemizer because the package is in the same place. Example: '''Console treehouse:~/workspace$ cd ~/workspace/com/teamtreehouse
treehouse:~/workspace/com/teamtreehouse$ javac Systemizer.java ''' will in fact compile because the file is now in the root of the directory the console is in, so '''javac Systemizer.java''' doesn't produce an error, whereas entering '''Console treehouse:~/workspace$ javac Systemizer.java
javac: file not found: Systemizer.java
Usage: javac <options> <source files>
use -help for a list of possible options " Produces the error: '''Console javac: file not found: Systemizer.java Usage: javac <options> <source files>
use -help for a list of possible options '''

The purpose of changing to the cd /tmp was to show how you how you can alter what directory the console is in(what I did with '''cd ~/workspace/com/teamtreehouse''') was then more what the classpath of the file is: your workspaces.

My understanding of the other questions is, Properties is an extension of Hashtable, which maps keys to values, has an initial capacity(defualt 11) and load-facor(default, expands initial capacity by 75%, 0.75), so .getProperties() returns Properties, which are a hashTable that maps the key of the propery name with value of properties. This is why Craig says Properties extends Hashtable, which extends Dictionary, the abstract for mapping any objects to keys with values.

hope this helps :)