unable to start uiautomatorviewer in windows due to classpath error - java

I am unable to start uiautomatorviewer due to below error:
C:\Users\176226\AppData\Local\Android\Sdk\tools\bin>uiautomatorviewer
-Djava.ext.dirs=..\lib\x86_64;..\lib is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I have added all the needed paths for tools, cmd-tools and platform tools and android_home in env variables
below are details of java version used. Can uiautomator be used without having to downgrade java version:
openjdk version "17.0.2" 2022-01-18 LTS
OpenJDK Runtime Environment Zulu17.32+13-CA (build 17.0.2+8-LTS)
OpenJDK 64-Bit Server VM Zulu17.32+13-CA (build 17.0.2+8-LTS, mixed mode, sharing)
Appreciate help

this was a real adventure....
download and install specifically JDK version 8 (not JRE or any other version)
https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html
add JDK8 to your environemnt path as JAVA_HOME..for example:
make sure %ANDROID_HOME%\tools\bin is also added to your Path as well so that you can run uiautomatorviewer from any directory
in terminal, run uiautomatorviewer

Related

How do I properly set up java paths and other system variables to start monkeyrunner?

When I first attempted to run monekyrunner.bet I got some error about java not being found. At that moment java.exe was at C:\Program Files\Android\Android Studio\jre\bin\java.exe which came with the latest android studio installation (Android Studio Dolphin | 2021.3.1 Patch 1; Runtime version: 11.0.13+0-b1751.21-8125866 amd64). I added this path to JAVA_HOME system variable, but I kept getting the same error.
java version:
openjdk 11.0.13 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
OpenJDK 64-Bit Server VM (build 11.0.13+0-b1751.21-8125866, mixed mode)
I then downloaded jdk-19 from https://www.oracle.com/java/technologies/downloads/#jdk19-windows as recommended in the moneyrunner error text. Now I have another java.exe at C:\Program Files\Java\jdk-19\bin\java.exe and I set C:\Program Files\Java\jdk-19\ in JAVA_HOME.
java version:
java 19.0.1 2022-10-18
Java(TM) SE Runtime Environment (build 19.0.1+10-21)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)
After this I started getting some error about SWT folder not existing. Reading this, I added an ANDROID_SWT system variable, which I have set to C:\Users\UserName\AppData\Local\Android\Sdk\tools\lib\x86_64\.
After this I got some error about monkeyrunner-26.0.0-dev.jar. Reading this, I modified the monkeyrunner bat file as explained in the post, but now I am getting
this error:
-Djava.ext.dirs=.;C:\Users\UserName\AppData\Local\Android\Sdk\tools\lib\x86_64"
-Dcom.android.monkeyrunner.bindir=..\framework -jar .\..\lib\monkeyrunner-26.0.0-dev.jar is not supported. Use
-classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
.
System variables:
ANDROID_SWT : C:\Users\UserName\AppData\Local\Android\Sdk\tools\lib\x86_64\
JAVA_HOME: C:\Program Files\Android\Android Studio\jre\
Is there a step by step guide on how exactly to start monkeyrunner? I want to send input events through monkeyrunner, as shown here.

Grakn Install: Java version unsupported

One is trying to run Grakn from Arch Linux system. On
./grakn server start, one gets the following error message (along with the instruction to check grakn server status or log files, which do not reveal anything).
Unsupported Java version [14] found. Grakn needs Java 1.8 in order to run.
java --version gives the following:
openjdk 14.0.2 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12)
OpenJDK 64-Bit Server VM (build 14.0.2+12, mixed mode)
Clearly, the Java version is more updated, and may not be the issue. How can one resolve this? One really wants to use Grakn, but does not wish to install Ubuntu to run that. Any help would be appreciated.
For checking java versions available on Arch Linux, use
archlinux-java status
For changing versions, use
sudo archlinux-java set <option>
An example is displayed below:

Java appears to be outdated when using java -jar command

I have recently been writing some Java programs on my Windows computer. I have been trying to use java -jar to run compiled jars in order to see errors more clearly, but when I try to do this, I get the following error:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/company/app/GUI has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the Java Runtime only recognizes class file versions up to 52.0
This obviously means that my java version is outdated. However, when I took a look at the Java Updater, it shows that I am running the latest version.
Running java -version shows this:
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) Client VM (build 25.261-b12, mixed mode)
So why is Command Prompt using an older version, and how do I change it?
Thank you for your help.
This error clearly indicates that you try to run a .jar file built with JDK 13 (major version 57) on a JRE/JDK 8 (major version 52) which is provided in PATH setting and thus invoked when running java -jar / java -version commands.
If you have JDK 13 installed on your machine, you need to check environment variable PATH and/or JAVA_HOME:
C:\Users\hp1>echo %JAVA_HOME%
C:\Java\jdk-13.0.2
C:\Users\hp1>echo %PATH%
C:\Windows\system32;C:\Java\jdk-13.0.2\bin
C:\Users\hp1>java -version
openjdk version "13.0.2" 2020-01-14
OpenJDK Runtime Environment (build 13.0.2+8)
OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)
If PATH refers JRE/JDK 8, you may create another variable and update PATH (copy non-java paths):
>set JAVA_13=**path_to_your_jdk_13**
>set PATH=C:\Windows\system32;%JAVA_13%\bin
If you do not have JDK 13 on your machine, to resolve this issue you should rebuild the .jar file to make it compatible with JDK 8 providing that the code is not using any features from the newer versions.

elasticsearch install plugin: Could not reserve enough space for object heap

I am trying to install the elasticsearch plugin with the command: ./plugin install license which I found on this tut: link
But I get the error message:
Error occurred during initialization of VM
Could not reserve enough
space for object heap Error: Could not create the Java Virtual
Machine. Error: A fatal exception has occurred. Program will exit.
After that even if I run java -version I get the same error! Before I run ./plugin install license java -version worked fine and printed:
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.14.04.1)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
Does anybody know whats my problem here? Its a fresh install of Ubuntu 14.04.4 LTS and I installed elasticsearch 2.2.3
Installation for ElasticSearch
1) Comment entry in C:\\elasticsearch-5.4.0\elasticsearch-5.4.0\config\jvm.options
#-Xms2g
#-Xmx2g
2) set ES_JAVA_OPTS as below in elasticsearch.bat
set ES_JAVA_OPTS = "-Xms512m -Xmx512m"

Weblogic10.3.5 install: Unrecognized option: -d64

Im trying to set up weblogic in my machine.
I downloaded from http://www.oracle.com/technetwork/middleware/ias/downloads/wls-main-097127.html.
My PATH looks like this, C:\Program Files\Java\jdk1.5.0_22\bin;
Java - version in cmd prompt gives this,
C:\setups>java -version
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_22-b03, mixed mode)
Now, when i execute the weblogic jar file using the command as specified in the oracle documentation, C:\setups>java -d64 -jar wls1035_generic.jar , I get the below error.
Unrecognized option: -d64
Could not create the Java virtual machine.
How should i get rid and execute the jar file to install weblogic? pls help.
I was having this issue. It happened because I had a 32bit JDK and not the 64bit JDK that was required by the weblogic install package
To check what version you have, you type the following in your terminal
java -d64 -version
If you get an error then that is your issue, proceed as below:
You can find the 64bit jdk at: Oracle
I think to avoid conflicts you might want to delete your current JDK

Categories