1
1
# Packages
2
2
3
3
#### What / Why?
4
- > A package is a group of class files.
5
-
6
-
7
- > Packages help organize your code.
8
-
9
-
10
- > Packages help keep your code unique from other people so you can resolve conflicts in your code if you have two or more classes with the same name.
4
+ * A package is a group of class files.
5
+ * Packages help organize your code.
6
+ * Packages help keep your code unique from other people so you can resolve conflicts in your code if you have two or more classes with the same name.
11
7
12
8
13
9
#### Naming conventions
@@ -17,7 +13,7 @@ package com.site.packagename;
17
13
package net.site.packagename ;
18
14
package org.site.packagename ;
19
15
20
- // using your initials or company name
16
+ // using your initials and/ or company name
21
17
package jre.packagename
22
18
package jre.companyname.packagename ;
23
19
```
@@ -53,29 +49,34 @@ javac -d ./ ./source1/*.java ./source2/*.java
53
49
```
54
50
55
51
#### Running classes within packages
56
- > If in different directory.
52
+ > If in different directory.
53
+
57
54
```
58
55
java -cp c:\location\of\packages full.packagename.ClassName
59
56
```
60
57
61
- > If in the package directory.
58
+ > If in the package directory.
59
+
62
60
```
63
61
java full.packagename.ClassName
64
62
```
65
63
66
64
#### Windows trick to get a list of all your projects java files
67
- > c:/location/of/source/files/update-sources.cmd
65
+ > c:/location/of/source/files/update-sources.cmd
66
+
68
67
```
69
68
dir /s /b *.java > sources.txt
70
69
```
71
70
72
71
#### Using our ` sources.txt ` file
73
- > Compiles all your java files to the current directory.
72
+ > Compiles all your java files to the current directory.
73
+
74
74
```
75
75
javac -d ./ @sources.txt
76
76
```
77
77
78
- > Compiles all your java files to a folder called bin, in the current directory.
78
+ > Compiles all your java files to a folder called bin, in the current directory.
79
+
79
80
```
80
81
javac -d ./bin @sources.txt
81
82
```
0 commit comments