|
1 | 1 | --- |
2 | 2 | title: Can't access elements of a Java application |
3 | 3 | description: Troubleshoot the issue that Power Automate for desktop can't access the elements of a Java desktop application. |
4 | | -ms.reviewer: pefelesk |
5 | | -ms.date: 04/29/2025 |
| 4 | +ms.reviewer: pefelesk, mitsirak, nimoutzo |
| 5 | +ms.author: iomimtso |
| 6 | +ms.date: 11/26/2025 |
6 | 7 | ms.custom: sap:Desktop flows\UI or browser automation |
7 | 8 | --- |
8 | 9 | # Can't access the elements of a Java application |
@@ -30,57 +31,67 @@ To solve this issue, try the [troubleshooter](/power-automate/desktop-flows/trou |
30 | 31 |
|
31 | 32 | If the issue persists after using the troubleshooter, follow these steps to manually troubleshoot the issue: |
32 | 33 |
|
33 | | -1. Ensure that you have Java installed on your machine: |
| 34 | +## 1. Manually configure Java (only for Java 7 and 8) |
34 | 35 |
|
35 | | - - Open the Command Line tool (cmd) and run the following command: |
| 36 | +Use these steps only if the troubleshooter finds no Java installations or cannot configure the environment. |
36 | 37 |
|
37 | | - ```cmd |
38 | | - java –version |
39 | | - ``` |
| 38 | +### A. Locate the Java installation folder |
40 | 39 |
|
41 | | - - If Java isn't installed, you receive an error message: |
| 40 | +- Check common paths such as `C:\Program Files\Java\jre7` or `C:\Program Files\Java\jre8`. |
| 41 | +- Some apps use an embedded Java runtime that is not registered system-wide. Start the Java application, open Task Manager, find the `java.exe` process, right-click it, and choose **Open file location**. Use that folder as `<JRE_HOME>\bin`. |
| 42 | +- To avoid this issue in future, install Java under `Program Files` or enable the option to register Java in the system registry during installation. |
42 | 43 |
|
43 | | - > 'java' is not recognized as an internal or external command, operable program or batch file. |
| 44 | +### B. Copy required files (administrator rights required) |
44 | 45 |
|
45 | | -2. Ensure that the **Enable Java Access Bridge** option is disabled in the Control Panel. |
| 46 | +Copy these files from the Power Automate for desktop installation folder (C:\Program Files (x86)\Power Automate Desktop\dotnet\java-support): |
46 | 47 |
|
47 | | - Go to **Control Panel** > **Ease of Access** > **Optimize visual display** > **Java Access Bridge from Oracle, Inc. Providing Assistive Technology access to Java applications**, and then disable the **Enable Java Access Bridge** option. |
| 48 | +- `PAD.JavaBridge.jar` to `<JRE_HOME>\lib\ext\` |
| 49 | +- `Microsoft.Flow.RPA.Desktop.UIAutomation.Java.Bridge.Native.dll` (x86 or x64 depending on the Java architecture) to `<JRE_HOME>\bin\` |
48 | 50 |
|
49 | | - :::image type="content" source="media/cannot-access-java-application-elements/enable-java-access-bridge-option.png" alt-text="Screenshot of the Enable Java Access Bridge option in the Windows Control Panel." lightbox="media/cannot-access-java-application-elements/enable-java-access-bridge-option.png"::: |
| 51 | +### C. Update accessibility configuration |
50 | 52 |
|
51 | | -3. Ensure that specific files exist in one or more Java folders of the machine after the Power Automate for desktop installation. |
| 53 | +1. Open `<JRE_HOME>\lib\accessibility.properties` in a text editor. Create the file if it doesn't exist. |
| 54 | +2. Add or update this line: |
52 | 55 |
|
53 | | - To check the installed Java version and installation path on your machine: |
| 56 | + assistive_technologies=microsoft.flows.rpa.desktop.uiautomation.JavaBridge |
54 | 57 |
|
55 | | - 1. Type _Configure Java_ in the Windows search bar. |
56 | | - 1. Open Java Control Panel and go to the **Java** tab. |
57 | | - 1. Select **View**. |
| 58 | + If the line starts with `#`, remove the `#` to uncomment it. If other assistive technologies are listed, append the Microsoft value at the end, separated by a comma. |
58 | 59 |
|
59 | | - :::image type="content" source="media/cannot-access-java-application-elements/java-control-panel.png" alt-text="Screenshot of the Java Control Panel."::: |
| 60 | +Note: Manual file placement works only for Java 7 and 8. Java 9 and later do not support loading assistive technologies by this method. |
60 | 61 |
|
61 | | - 1. Check the values in the **Path** column. The **Architecture** row with value x86 refers to 32-bit Java installation, while the row with value x64 refers to 64-bit Java installation. |
| 62 | +## 2. Workaround for Java 9 and later (or when file placement is not possible) |
62 | 63 |
|
63 | | - :::image type="content" source="media/cannot-access-java-application-elements/java-runtime-environments-settings.png" alt-text="Screnshot of the Java Runtime Environment Settings."::: |
| 64 | +For Java 9+ you cannot modify the Java installation in the same way. Use one of these options. |
64 | 65 |
|
65 | | - Check that the following files exist: |
| 66 | +### A. Set environment variable (recommended) |
66 | 67 |
|
67 | | - - For 64-bit Java installation: |
| 68 | +Set a system or user environment variable named `JDK_JAVA_OPTIONS` with this value (64-bit example): |
68 | 69 |
|
69 | | - - File _Microsoft.Flow.RPA.Desktop.UIAutomation.Java.Bridge.Native.dll_ is replaced in folder _C:\Program Files\Java\jre1.8.0_271\bin_. (replace _jre1.8.0_271_ with your machine's Java installation folder.) |
70 | | - - File _accessibility.properties_ is replaced in folder _C:\Program Files\Java\jre1.8.0_271\lib_. (replace _jre1.8.0_271_ with your machine's Java installation folder.) |
71 | | - - If you open the file with Notepad, you should see the following value: |
72 | | - `assistive_technologies=com.sun.java.accessibility.AccessBridge, microsoft.flows.rpa.desktop.uiautomation.JavaBridge` |
73 | | - - File _PAD.JavaBridge.jar_ is inserted in folder _C:\Program Files\Java\jre1.8.0_271\lib\ext_. (replace _jre1.8.0_271_ with your machine's Java installation folder.) |
| 70 | +`-javaagent:"C:\Program Files (x86)\Power Automate Desktop\dotnet\java-support\PAD.JavaBridge.jar" -Djava.library.path="%PATH%;C:\Program Files (x86)\Power Automate Desktop\dotnet\java-support\x64"` |
74 | 71 |
|
75 | | - - For 32-bit Java installation: |
| 72 | +For 32-bit Java, use the `x86` folder instead of `x64`. |
76 | 73 |
|
77 | | - - Check the same files but in folder _C:\Program Files (x86) \Java…_. |
| 74 | +### B. Add JVM arguments to the Java application start command |
78 | 75 |
|
79 | | -4. Check _.accessibility.properties_ file: |
| 76 | +Append these arguments to the app's Java startup command: |
80 | 77 |
|
81 | | - - Ensure there isn't an _.accessibility.properties_ file in your _C:\Users\user_ folder. (replace _user_ with your user name.) |
82 | | - - If the file exists, rename it. |
| 78 | +- `-javaagent:"<PAD install path>\dotnet\java-support\PAD.JavaBridge.jar"` |
| 79 | +- `-Djava.library.path="<PAD install path>\dotnet\java-support\x64"` (or `x86`) |
83 | 80 |
|
84 | | -5. Ensure that _VC_redist.x64.exe_, _VC_redist.x86.exe_, or both are run. |
| 81 | +## Key clarifications and troubleshooting tips |
85 | 82 |
|
86 | | - :::image type="content" source="media/cannot-access-java-application-elements/installed-microsoft-visual-c-plus-plus-redistributable-versions.png" alt-text="Screenshot of the installed Microsoft Visual C++ Redistributable versions."::: |
| 83 | +- Always try the Power Automate for desktop Troubleshooter first. It's the safest and fastest method to configure Java automation. |
| 84 | +- Manual file placement applies only to Java 7 and 8. Use the environment-variable or JVM-argument method for Java 9 and later. |
| 85 | +- Java versions earlier than 7 are not supported. |
| 86 | +- The attach mechanism may not work reliably with Java 9 or Java 10. |
| 87 | +- Use Task Manager to find the Java executable path when an application uses an embedded runtime. |
| 88 | +- Administrator rights are required to place files in Java installation folders. |
| 89 | +- If you placed the files manually, they are not updated automatically when Power Automate for desktop is updated. Repeat the manual file placement after each Power Automate for desktop update to use the latest Java automation files. |
| 90 | +- After making changes, close all running Java applications. Restarting the PC is recommended. |
| 91 | + |
| 92 | +## More information |
| 93 | + |
| 94 | +- [Automate Java applications](/power-automate/desktop-flows/desktop-flows/how-to/java) |
| 95 | +- [Troubleshoot UI automation in Power Automate for desktop](/power-automate/desktop-flows/how-to/troubleshoot-ui-automation) |
| 96 | + |
| 97 | +[!INCLUDE [Third-party disclaimer](../../../../includes/third-party-disclaimer.md)] |
0 commit comments