Skip to content

Commit fe1fc59

Browse files
committed
docs(README): add info
1 parent 0141b07 commit fe1fc59

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

README.md

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ A Perl utility to extract Java version information from compiled Java class file
77
JavaInfo reads Java `.class` files and identifies the Java version used to compile them. It works by examining the bytecode header of each class file, specifically the magic number (`0xCAFEBABE`) and the major/minor version numbers that indicate the Java compiler version.
88

99
The tool can process individual files or recursively scan entire directories, making it useful for:
10+
1011
- Auditing Java dependencies and libraries
1112
- Verifying compilation targets in build artifacts
1213
- Identifying version mismatches in projects
@@ -39,34 +40,39 @@ The tool can process individual files or recursively scan entire directories, ma
3940
### Examples
4041

4142
**Analyze a single class file:**
43+
4244
```bash
4345
./JavaInfo MyClass.class
4446
```
4547

4648
**Scan a directory recursively:**
49+
4750
```bash
4851
./JavaInfo /path/to/project/target/classes
4952
```
5053

5154
**Process multiple paths:**
55+
5256
```bash
5357
./JavaInfo src/main/java build/classes lib/*.jar
5458
```
5559

5660
### Example Output
5761

58-
```
62+
```text
5963
MyClass.class: Java 11 [0/55]
6064
Utils.class: Java 8 [0/52]
6165
LegacyCode.class: Java 1.4.2 [0/48]
6266
```
6367

6468
The output format is:
65-
```
69+
70+
```text
6671
<filename>: Java <version> [<minor>/<major>]
6772
```
6873

6974
Where:
75+
7076
- `<filename>` is the path to the class file
7177
- `<version>` is the Java version (e.g., 8, 11, 17, or 1.4.2 for older versions)
7278
- `<minor>/<major>` are the bytecode version numbers
@@ -76,35 +82,36 @@ Where:
7682
The tool uses the following mapping between bytecode major versions and Java releases:
7783

7884
| Major Version | Minor Version | Java Version |
79-
|--------------|---------------|--------------|
80-
| 45 | 0-3 | 1.0.2 |
81-
| 45 | 4+ | 1.1.8 |
82-
| 46 | - | 1.2.2 |
83-
| 47 | - | 1.3.1 |
84-
| 48 | - | 1.4.2 |
85-
| 49 | - | 5 |
86-
| 50 | - | 6 |
87-
| 51 | - | 7 |
88-
| 52 | - | 8 |
89-
| 53 | - | 9 |
90-
| 54 | - | 10 |
91-
| 55 | - | 11 |
92-
| 56 | - | 12 |
93-
| 57 | - | 13 |
94-
| 58 | - | 14 |
95-
| 59 | - | 15 |
96-
| 60 | - | 16 |
97-
| 61 | - | 17 |
98-
| 62 | - | 18 |
99-
| 63 | - | 19 |
100-
| 64 | - | 20 |
101-
| 65 | - | 21 |
85+
| ------------- | ------------- | ------------ |
86+
| 45 | 0-3 | 1.0.2 |
87+
| 45 | 4+ | 1.1.8 |
88+
| 46 | - | 1.2.2 |
89+
| 47 | - | 1.3.1 |
90+
| 48 | - | 1.4.2 |
91+
| 49 | - | 5 |
92+
| 50 | - | 6 |
93+
| 51 | - | 7 |
94+
| 52 | - | 8 |
95+
| 53 | - | 9 |
96+
| 54 | - | 10 |
97+
| 55 | - | 11 |
98+
| 56 | - | 12 |
99+
| 57 | - | 13 |
100+
| 58 | - | 14 |
101+
| 59 | - | 15 |
102+
| 60 | - | 16 |
103+
| 61 | - | 17 |
104+
| 62 | - | 18 |
105+
| 63 | - | 19 |
106+
| 64 | - | 20 |
107+
| 65 | - | 21 |
102108

103109
For Java 5 and later, the formula is: **Java Version = Major Version - 44**
104110

105111
## Error Handling
106112

107113
The script will display error messages and exit if:
114+
108115
- A file cannot be opened or read
109116
- A directory cannot be accessed
110117
- A file is not a valid Java class file (missing the `0xCAFEBABE` magic number)

0 commit comments

Comments
 (0)