I am trying to execute the java command but every commands its goes for infinite loop.
for example
1.java -version
2.java -help
above both commands keep on running and never returns a result this problem occurs from today morning for every java commands ex : jps,jconsole etc.
->JAVA_HOME and PATH variable already defined.
which java
~/Java/jdk1.8.0_102/bin/java
and
echo $JAVA_HOME
/home/arc/Java/jdk1.8.0_102
and
file /home/arc/Java/jdk1.8.0_102/bin/java
/home/arc/Java/jdk1.8.0_102/bin/java: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
Problem is with GLIBC-2.12, recently I installed GLIBC-2.14 manually ,problem arise due to conflicting between them.
Related
Getting the following error when attempting to load the Oracle Weblogic installer:
tsugonko-1: ~/weblogic
→ java -jar fmw_12.2.1.4.0_wls_quick.jar
Launcher log file is /private/var/folders/jk/jjhksz9n6c354s25_pvj9qp80000gn/T/OraInstall2022-01-13_11-44-45AM/launcher2022-01-13_11-44-45AM.log.
Extracting the installer . . . . Done
Checking if CPU speed is above 300 MHz. Actual 2662.4 MHz Passed
Checking swap space: must be greater than 512 MB. Actual 145636 MB Passed
Checking if this platform requires a 64-bit JVM. Actual 64 Passed
Checking temp space: must be greater than 300 MB. Actual 145636 MB Passed
Preparing to launch the Oracle Universal Installer from /private/var/folders/jk/jjhksz9n6c354s25_pvj9qp80000gn/T/OraInstall2022-01-13_11-44-45AM
Unrecognized option: -d64
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
1. First, I have verified that the installer script is present, but don't know how to verify that it is actually loading:
tsugonko-1: /private/var/folders/jk/jjhksz9n6c354s25_pvj9qp80000gn/T/OraInstall2022-01-13_11-44-45AM
→ ls
OPatch launcher2022-01-13_11-44-45AM.log oui
install13817544693051062390.sh oracle_common
2. I believe my $JAVE_HOME path is correct:
→ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home
→ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home/bin
(notice that "bin" is not included in the /usr/libexec path, I removed the /bin from the $JAVA_HOME path, but that did not correct the issue)
3. And I believe I have correctly listed the PATH in the ~/.bash_profile (Mac OS, no .bashrc, amended file output to the actual PATH variable
tsugonko-1: /Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home/bin
→ cat ~/.bash_profile
#!/usr/bin/env bash
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home/bin
export PATH=/Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home/bin:$PATH
export ORACLE_HOME=~/Applications/Oracle
(Notice I have two variable paths, I commented one out then the other, but this did not correct the issue either), internet search suggested both, but I assume one is best practice)
Any suggestions from the group? Incidentally, I did have weblogic server installer, but it got corrupted: I could load the admin server, but not any managed servers, so I deleted the files (rm -rf weblogic).
Is it possible I did not properly uninstall weblogic and there is a zombied process preventing the installer to hook the JVM or otherwise not load?
WebLogic Server 12.2.1.4 does not support java 16 but only java 8 and java 11.
Also, it is only supported with Oracle JDK and not OpenJDK.
This question already has answers here:
uiautomatorviewer - Error: Could not create the Java Virtual Machine
(11 answers)
Closed 1 year ago.
The following error is displayed when the command is executed:
username#device:~/Android/Sdk/tools/bin$ ./uiautomatorviewer
Djava.ext.dirs=/home/username/Android/Sdk/tools/lib/x86_64:/home/username/Android/Sdk/tools/lib is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
then I use --class-path in uiautomatorviewer file and face this error:
I use this method for editing uiautomatorviewer file: https://www.programmersought.com/article/53371586152/
error: unable to initialize main class com.android.uiautomator.uiautomatorviewer caused by: java.lang.noclassdeffounderror: org/eclipse/swt/widgets/control
mychange:enter image description here
original:enter image description here
And when I got the above error, I turned back to the previous state
And now I have the first issue again.
extera information:
$JAVA_HOME => /usr/lib/jvm/java-8-openjdk-amd64
$ANDROID_HOME => /home/username/Android/Sdk
Android studio version: 4.1.3
This is the output that I asked for in the comments.
+java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)
+exec java -Xmx1600M -Djava.ext.dirs=/home/alielyasi/Android/Sdk/tools/lib/x86_64:/home/alielyasi/Android/Sdk/tools/lib -Dcom.android.uiautomator.bindir=/home/alielyasi/Android/Sdk/tools -jar /home/alielyasi/Android/Sdk/tools/lib/uiautomatorviewer-26.0.0-dev.jar
-Djava.ext.dirs=/home/alielyasi/Android/Sdk/tools/lib/x86_64:/home/alielyasi/Android/Sdk/tools/lib is not supported.
Use -classpath
Firstly, we can see that the Java command that is being used is java, not a specific (absolute) pathname.
That is OK, but it means that $PATH will be used to resolve java to the actaul pathname of a Java launcher. (Not $JAVA_HOME.)
Second, we can see that java -version is telling us that it is using Java 11.0.11. As I mentioned in my comments, Java 9 and later do not support the "ext.dirs" mechanism.
Unfortunately, the java command's suggestion to use -classpath is not going to work (as-is).
So I am going to give you two ways to solve this:
Solution #1: Just use Java 8.
You need to make sure that you have Java 8 installed, and that running the java -version prints out that that the version number is 8.0.xxx, where xxx is (ideally) the latest available Java 8 patch release.
Since you are using using Ubuntu 20.04, there are two ways to make sure that you are using Java 8 rather than Java 11.
You could make Java 8 the default Java version globally using the "alternatives" system. Run man update-alternatives for the documentation. (You need to run update-alternatives as root ...)
You could make Java 8 the default for the current user or the current shell by changing the PATH environment variable.
Solution #2: Adjust the script so that Java 11 will work.
As I said above, simply converting -Djava.ext.dirs=... into a -classpath option doesn't work. That is because the exec line is using the -jar option, and when -jar is used -classpath is ignored. But -jar means this is an "executable JAR", and the entrypoint class name is coming from the JAR file's manifest.
So we need to unpick this.
First we need to know what the (full) entrypoint class name is, and also JAR file is setting its own classpath. We can determine by using the jar command to extract the META-INF/MANIFEST.MF file and looking it.
Next we need to form a classpath consisting of
the path that is currently given by $frameworkdir
the path for the main JAR file (i.e. $jarpath)
the path specified in the manifest file
The order of the path could be significant.
The entire classpath needs to be given to the java command via a -classpath or -cp option. (Not --class-path.)
Finally remove -jar $jarpath and replace it with the full entrypoint class name. (It is a class name, not a pathname. Don't change the dots to slashes, add a suffix or do anything like that. Use the name exactly as the manifest file gives it.)
This approach should work, but I can't test it. If it fails, please comment below.
I've java 1.8.0_131 by default on my machine but also java 9, so can I run a compiled class with jdk-9? is it possible anything like this:
java -v path/to/jdk-9 myClass
Thanks
The java command actually invokes the JVM. That JVM starts up, and reads your classes, and runs what you tell it to run.
There is no way to tell the "starting" JVM to actually use a different JVM. java isn't some sort of wrapper that "later" invokes some binary. It is already the binary that starts the JVM.
In other words: what you are asking for isn't possible. A simple workaround can be to define "aliases" on the command line, like java-8 to start your java8 installation, and java-9 to point to that other installation.
By default java command call the installed java version which can be checked by command:
One way could be update the java:
sudo update-alternatives --config java.
O/P of above command:
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 auto mode
* 1 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 manual mode
Press <enter> to keep the current choice[*], or type selection number:
In your case java 9 will also come. update java version and run java command.
Or you can do directly call your java9 script which you can find ${Java9 Installation Directory}/jre/bin/java -v class.
PS: Above description of commands is based on ubuntu.
So my problem is why when I execute "java -version" command as root in my cent os it gives me "java runtime 1.7". But when I use ssh to ssh the same root user and execute "java -version", I got "java JDK 1.6" and this problem causing my deploy activity not working. So anyone know, why I got different result when use ssh command and not.
Thanks all...
The problem is due to setting of $PATH being different in the two contexts.
Run echo $PATH and which java in both contexts and compare the results.
Irrespective of why the $PATH settings are different, one solution is to use the absolute pathname for the java binary that you want.
It is also worth noting that both Java 6 and Java 7 are passed EOL, and you should really be upgrading your applications to use Java 8. Especially if you are using Java to run network-exposed services ... or (>>shudder<<) in a web browser.
Chances are your root login has a different PATH environment variable setting than your ssh login shell.
which java will probably (depending which shells you're using) tell you which java binary is first in your PATH.
I have two installations of JDK on my account and I do not have root access to change the default one which is "usr/bin/java" to specific one /home/username/jdk/bin/java"
I tried to do the following in my php code:
$JAVA_HOME = "/home/username/jdk";
$PATH = "$JAVA_HOME/bin:".getenv('PATH');
putenv("JAVA_HOME=$JAVA_HOME");
But when I execute the following just below above mentioned lines:
which java
I got /usr/bin/java
Any idea please how to make it works? The java application I want to run from php code does not work on the default one.
Thanks
If feasible, qualify the java command, e.g. /home/username/jdk/bin/java, when running your Java program.
This way you can even use multiple different JVM's in different places of your PHP code.
Note: I know that using qualified access like this works on Windows, even if JAVA_HOME points to a different installation. I'm assuming the same is true for Linux.
Try to set JAVA_HOME as temporary parameter for the context of your application, i.e. right before the command (see the second command, the others just show that the variable is only set for that one command):
> java -version
java version "1.8.0"
> JAVA_HOME=~/jdk1.7.0_51.jdk/ java -version
java version "1.7.0_51"
> java -version
java version "1.8.0"
In PHP:
exec("JAVA_HOME=~/jdk1.7.0_51.jdk/ java yourapplication");
Source: Bash Reference Manual – Environment
The environment for any simple command or function may be augmented temporarily by prefixing it with parameter assignments, as described in Shell Parameters. These assignment statements affect only the environment seen by that command.
To see the differences in a browser I tested with this ugly PHP snippet:
<?php
echo "<pre>" . shell_exec('java -version 2>&1') . "</pre>";
echo "<pre>" . shell_exec('JAVA_HOME=~/jdk1.7.0_51.jdk java -version 2>&1') . "</pre>";
echo "<pre>" . shell_exec('~/jdk1.7.0_51.jdk/bin/java -version 2>&1') . "</pre>";
?>
You may also use a specific version of the java executable by explicitly using it to run your app:
shell_exec("~/jdk1.7.0_51.jdk/bin/java -version");