I got so engrossed in watching movies and playing games yesterday that I did not get back to the blog and learn how to use CardLayout :S. Watching too many movies can be quite taxing on the mind as I felt that I did not achieve much during the day :S. Oh well, what's done is done and its back to business. This time I am going to blog about Java compiling using the -d (directory) flag.
Because I have been using Netbeans all this time, I learned that even though Netbeans made many things easier, it is not the best way to relearn or learn Java. The directories and java paths and imports when creating through Netbeans are all managed automatically and while this would make it easier for Java Developers, I feel that while re-learning Java, it would be better to go back to the basics of using command line and understanding what is happening. This post will be dedicated to simple compiling of java, especially with the directory flag.
When it comes to making my own project I have decided to start using packages when it comes to my java files. I will try to compile each java file under the general packages of "net.sambel.samuel.tambunan.***" where *** are the package names. So for example, if MyApp is a package and MyAppClass is the first java class in the package, i would have to run it under
javac net/sambel/samuel/tambunan/MyApp/*.java;
When using the -d (directory) flag,
I can type javac -d ../classes net/sambel/samuel/tambunan/MyApp/*.java
to compile everything from inside net/sambel/samuel/tambunan/MyApp/*.java and put all the compiled classes into a separate folder in
classes/net/sambel/samuel/tambunan/MyApp
This would help me keep all my java source codes in a separate folder form my classes files.
So my overall directories would look in the end like
MyProject -> source ->net -> sambel -> samuel -> tambunan ->MyApp -> ***.java
-> classes ->net -> sambel -> samuel -> tambunan ->MyApp -> ***.class
NOTE: when compiling using:
javac net/sambel/samuel/tambunan/MyApp/*.java;
be sure that you are inside the source directory.
No comments:
Post a Comment