[last updated: 2019-05-28]
go to: Java
go to: Java-Editing, Compiling, Executing
-----
Researching tutorials and forums, this is my best guess at the moment:
- There are several ways to organize directories and files for Java.
To some degree it depends on what environment you're using, whether Maven or other options I have no clue about.
Bottom line is there is no one right way, so you're left to do what works for you.
- I'm still confused about (at least) a couple of things:
Is it correct (as I've done it) to put net.jayrabe under the src.main?
Is it correct (as I've done it) to put jar files in a lib directory that is parallel to src & bin?
- In any case, these instructions are what make the most sense for me at this moment:
- [somewhere...] directories to identify the domain of your company/organization:
net, or com, or org, or whatever
- Next directory will be your company name: jayrabe in my case
- [somewhere...] will be two directories, src and bin
- Under the src and bin directories will be an identical structure, drilling down into the packages in your project.
- The src branch will contain source files with a .java extension.
- The bin branch will contain compiled files with a .class extension.
- ...
projectName
|-- src
.....|-- main
..........|-- net
...............|-- jayrabe
....................|-- package1
.........................[This is a directory/package. Its name starts with lower-case.]
.........................[This package contains source (.java) files.
..............................Each source file defines one class.]
.........................Class1.java [source file (.java) names are capitalized/CamelCase]
..............................[first line in the source file: package main.net.jayrabe.package1;]
.........................Class2.java
..............................[first line in the source file: package main.net.jayrabe.package1;]
..........................[packages can also contain other (sub-)packages:]
..........................|--package1a
..............................Class3.java
...................................[first line in the source file: package main.net.jayrabe.package1.package1a;]
.....|-- test
|-- bin
.....[Under this bin directory will be a structure identical to that under src.]
.....|-- main
..........|-- net
...............|-- jayrabe
....................|-- package1
..........................|--package1a
.....|-- test
|---- lib
.......|---- [jar files?]
.
.
.
eof