Skip to content

Commit 5fbfa68

Browse files
committed
Upgrade examples
1 parent 9ca3716 commit 5fbfa68

File tree

30 files changed

+1624
-1643
lines changed

30 files changed

+1624
-1643
lines changed

README.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44

55
*Java Does USB* is a Java library for working with USB devices. It allows to query information about all conntected USB devices and to communicate with USB devices using custom / vendor specific protocols. (It is not intended for communication with standard types of USB devices such as mass storage devices, keyboards etc.)
66

7-
The library uses the [Foreign Function & Memory API](https://github.com/openjdk/panama-foreign) to access native APIs of the underlying operating system. It is written entirely in Java and does not need JNI or any native third-party library. The *Foreign Function & Memory API* (aka as project Panama) is currently in preview and will leave preview with Java 22. Currently, it can be used with Java 19, Java 20 or Java 21 (with preview features enabled).
7+
The library uses the [Foreign Function & Memory API](https://github.com/openjdk/panama-foreign) to access native APIs of the underlying operating system. It is written entirely in Java and does not need JNI or any native third-party library. The *Foreign Function & Memory API* (aka as project Panama) has been introduced with Java 22. Older versions of this library can be used with preview versions of the API that were available in Java 19, Java 20 or Java 21 (with preview features enabled).
88

99
| Version | Main New Features | Compatibility |
1010
| - | - | - |
11+
| 1.0.x | Release for final Java API | JDK 22 |
1112
| 0.7.x | New setter/getter names for improved Kotlin support; Kotlin examples | JDK 21 |
1213
| 0.6.x | Support for JDK 21; better handling of composite devices on Windows | JDK 21 |
1314
| 0.5.x | Support for JDK 20; high-throuput I/O streams | JDK 20 |
1415
| 0.4.x | Early release | JDK 19 |
1516

16-
*Note: The main branch and published versions ≥ 0.6.0 work with JDK 21 only. For JDK 20, use version 0.5.*. For JDK 19, use version 0.4.x.
17+
*Note: The main branch and published versions ≥ 1.0 work with JDK 22 and later only. For JDK 21, user version 0.7.*. For JDK 20, use version 0.5.*. For JDK 19, use version 0.4.x.
1718

1819

1920
## Features
@@ -48,14 +49,14 @@ If you are using Maven, add the below dependency to your pom.xml:
4849
<dependency>
4950
<groupId>net.codecrete.usb</groupId>
5051
<artifactId>java-does-usb</artifactId>
51-
<version>0.7.1</version>
52+
<version>1.0.0-SNAPSHOT</version>
5253
</dependency>
5354
```
5455

5556
If you are using Gradle, add the below dependency to your build.gradle file:
5657

5758
```groovy
58-
compile group: 'net.codecrete.usb', name: 'java-does-usb', version: '0.7.1'
59+
compile group: 'net.codecrete.usb', name: 'java-does-usb', version: '1.0.0-SNAPSHOT'
5960
```
6061

6162
```java
@@ -90,23 +91,23 @@ public class EnumerateDevices {
9091

9192
## Prerequisite
9293

93-
- Java 21, preview features enabled (available at https://www.azul.com/downloads/?package=jdk)
94+
- Java 22 (available at https://www.azul.com/downloads/?package=jdk)
9495
- Windows (x86 64-bit), macOS (x86 64-bit, ARM 64-bit) or Linux 64 bit (x86 64-bit, ARM 64-bit)
9596

96-
For JDK 20, use the latest published version 0.5.x. For JDK 19, use the latest published version 0.4.x.
97+
For JDK 21, use the latest published version 0.7.x. For JDK 20, use the latest published version 0.5.x. For JDK 19, use the latest published version 0.4.x.
9798

9899

99100
## Platform-specific Considerations
100101

101102

102103
### macOS
103104

104-
No special considerations apply. Using this library, a Java application can connect to any USB device and claim any interfaces that isn't claimed by an operating system driver or another application. Standard operation-system drivers can be unloaded if the application is run with root privileges.
105+
No special considerations apply. Using this library, a Java application can connect to any USB device and claim any interfaces that isn't claimed by an operating system driver or another application. Standard operation-system drivers can be unloaded if the application is run with root privileges. It runs both on Macs with Apple Silicion and Intel processors.
105106

106107

107108
### Linux
108109

109-
*libudev* is used to discover and monitor USB devices. It is closely tied to *systemd*. So the library only runs on Linux distributions with *systemd* and the related libraries. The majority of Linux distributions suitable for desktop computing (as opposed to distributions optimized for containers) fulfill this requirement.
110+
*libudev* is used to discover and monitor USB devices. It is closely tied to *systemd*. So the library only runs on Linux distributions with *systemd* and the related libraries. The majority of Linux distributions suitable for desktop computing (as opposed to distributions optimized for containers) fulfill this requirement. It runs on both Intel and ARM64 processors.
110111

111112
Similar to macOS, a Java application can connect to any USB device and claim any interfaces that isn't claimed by an operating system driver or another application. Standard operation system drivers can be unloaded (without the need for root privileges).
112113

@@ -129,17 +130,11 @@ USB devices can implement certain control requests to instruct Windows to automa
129130

130131
The test devices implement the required control requests. So the driver is installed automatically.
131132

132-
The library has not been tested on Windows for ARM64. It might or might not work.
133+
Windows for ARM64 is not yet supported. A port is probably easy, provided you have hardware to test it.
133134

134135

135136
### Troubleshooting
136137

137-
#### `ClassFormatError` (all platforms)
138-
139-
The error `java.lang.ClassFormatError: Illegal field name "" in class net/codecrete/usb/windows/WindowsUsbDeviceRegistry` is caused by a bug in JDK 21, which has been fixed in the mean-time. Please upgrade to the latest release of JDK 21 (at least 21.0.1).
140-
141-
142-
143138
### 32-bit versions
144139

145140
The Foreign Function & Memory API has not been implemented for 32-bit operating systems / JDKs (and likely never will be).
@@ -170,11 +165,11 @@ mvn clean test
170165
If they are run from an IDE (such as IntelliJ IDEA), you must likely configure VM options to enable preview features and allow native access:
171166

172167
```
173-
--enable-preview --enable-native-access=net.codecrete.usb
168+
--enable-native-access=net.codecrete.usb
174169
```
175170

176171
Or (if modules are ignored):
177172

178173
```
179-
--enable-preview --enable-native-access=ALL-UNNAMED
174+
--enable-native-access=ALL-UNNAMED
180175
```

examples/bulk_transfer/.mvn/wrapper/maven-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
1818
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar

examples/bulk_transfer/README.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ This sample shows how to find a device, open it and transfer data from and to bu
44

55
## Prerequisites
66

7-
- Java 21
7+
- Java 22
88
- Apache Maven
99
- 64-bit operating system (Windows, macOS, Linux)
1010
- A USB device with bulk IN and OUT endpoints (e.g. the test device, see https://github.com/manuelbl/JavaDoesUSB/tree/main/test-devices/loopback-stm32)
1111

1212
## How to run
1313

14-
### Install Java 21
14+
### Install Java 22
1515

16-
Check that *Java 21* is installed:
16+
Check that *Java 22* is installed:
1717

1818
```shell
1919
$ java -version
@@ -39,24 +39,22 @@ $ mvn compile exec:exec
3939
[INFO] Scanning for projects...
4040
[INFO]
4141
[INFO] --------------< net.codecrete.usb.examples:bulk-transfer >--------------
42-
[INFO] Building bulk-transfer 0.7.1
42+
[INFO] Building bulk-transfer 1.0.0-SNAPSHOT
4343
[INFO] --------------------------------[ jar ]---------------------------------
4444
[INFO]
45-
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ bulk-transfer ---
46-
[INFO] Using 'UTF-8' encoding to copy filtered resources.
47-
[INFO] skip non existing resourceDirectory /Users/me/Documents/JavaDoesUSB/examples/bulk_transfer/src/main/resources
45+
[INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ bulk-transfer ---
46+
[INFO] skip non existing resourceDirectory /home/user/Documents/JavaDoesUSB/examples/bulk_transfer/src/main/resources
4847
[INFO]
49-
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ bulk-transfer ---
50-
[INFO] Changes detected - recompiling the module!
51-
[INFO] Compiling 1 source file to /Users/me/Documents/JavaDoesUSB/examples/bulk_transfer/target/classes
48+
[INFO] --- maven-compiler-plugin:3.12.1:compile (default-compile) @ bulk-transfer ---
49+
[INFO] Nothing to compile - all classes are up to date.
5250
[INFO]
53-
[INFO] --- exec-maven-plugin:3.1.0:exec (default-cli) @ bulk-transfer ---
51+
[INFO] --- exec-maven-plugin:3.1.1:exec (default-cli) @ bulk-transfer ---
5452
6 bytes sent.
5553
6 bytes received.
5654
[INFO] ------------------------------------------------------------------------
5755
[INFO] BUILD SUCCESS
5856
[INFO] ------------------------------------------------------------------------
59-
[INFO] Total time: 1.259 s
60-
[INFO] Finished at: 2023-03-23T14:10:17+01:00
57+
[INFO] Total time: 1.228 s
58+
[INFO] Finished at: 2024-02-18T16:23:29+01:00
6159
[INFO] ------------------------------------------------------------------------
6260
```

0 commit comments

Comments
 (0)