Modifying JDK Path for Oracle SQL Developer in Ubuntu - java

I have Oracle SQL Developer installed at the following location:
/opt/sqldeveloper
Every time I run it using the command ./sqldeveloper, I get the following error from the GUI:
You are attempting to run with Java 1.6.0_31. Running this product is
supported with a minimum Java version of 1.7.0_51 and less than 1.8
I updated the sqldeveloper.conf file with the following paths:
/usr/java/jdk1.8.0_05
and
/usr/java/jdk1.7.0_55
And despite all that, same error again.

I know I am a bit late with the response, but I had exactly the same issue until this morning.
What I did is changed:
~/.sqldeveloper/4.0.0/product.conf
FYI:
How I figure it out:
1. Go to OracleSQLDeveloper -> Help(menu) -> Properties
2. Find 'java.home'
(For some reason it was pointing to /usr/lib/jdk1.7.0 (ver 1.7.45), even I've changed sqldeveloper.conf)
3. Since I didn't recognized that specific version, I just ran:
sudo "find / .... -name '*.conf' -exec grep 'jdk1.7.0' ..."
goodluck

Configure Path to Java
SQL-Developer needs to know how to find your Java Developer Kit:
Note: You need to specify /usr/lib/jvm/java-6-openjdk-i386 on 32-bit OS installations.
Terminal
cd $HOME
mkdir -p .sqldeveloper
cd $HOME/.sqldeveloper
echo "/usr/lib/jvm/java-6-openjdk" > jdk

Related

Ant not using my JAVA_HOME to find tools.jar

I realize that this question is going to initially sound like a duplicate of some other questions, but none of the other questions I've looked at fixed my issue.
The short story is that I have a JRE and a JDK installed at different locations. I set JAVA_HOME to point to the JDK, yet ant seems to still search for tools.jar in the JRE location. I'm not sure if this has more to do with my ant installation/configuration, or my JDK installation/configuration.
Here's the long story:
Environment
I am running on Red Hat Enterprise Linux Server release 7.5 (Maipo) on an account that does not have sudo privileges to anything.
My JDK install
The machine already has the JRE installed at /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/jre/bin/java. I am not allowed to modify that install, but I can create my own java installation in a separate location.
The security requirements on my network are very stringent and I am only allowed to put specific pieces of software on the machine. It is possible to ask permission for other pieces of software, but I have to go through an approval process that is a huge pain. I have obtained permission to put JDK 1.8 from openJDK on the machine.
Since openJDK does not release tar balls of the whole installation and since I don't have sudo permissions I attempted to install the JDK by downloading java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64.rpm and java-1.8.0-openjdk-devel-1.8.0.172-13.b11.fc29.x86_64.rpm to /local/apps/openJDK8 and running (from /local/apps/openJDK8)
rpm2cpio < java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64.rpm | cpio -i --make-directories
rpm2cpio < java-1.8.0-openjdk-devel-1.8.0.172-13.b11.fc29.x86_64.rpm | cpio -i --make-directories
For some reason this doesn't seem to do a complete JDK install (I think I must be missing some dependencies). I discovered that libjava.so, libjvm.so, jvm.cfg, and the server folder were missing, so I just created some links to the JRE install that had them (run from local/apps/openJDK8):
ln -s /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/lib/amd64/jvm.cfg usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64/lib/amd64/jvm.cfg
ln -s /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/lib/amd64/libjava.so usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64/lib/amd64/libjava.so
ln -s /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/lib/amd64/libjvm.so usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64/lib/amd64/libjvm.so
ln -s /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/lib/amd64/server usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64/lib/amd64/server
That step makes me a little nervous, so it could be part of my problem. At any rate, javac and java seem to work fine.
ANT INSTALL
For my ant installation, I just downloaded a tar ball and extracted it to /local/apps/ant and then did:
export JAVA_HOME=/local/apps/openJDK8/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64
export ANT_HOME=/local/apps/ant/apache-ant-1.10.4
I didn't bother updating the path because for now I'm just using fully qualified paths for everything. My ultimate goal is to have Jenkins running all of this anyway and it just uses fully qualified paths.
Results
Now if I try to run ant, I get:
> /local/apps/ant/apache-ant-1.10.4/bin/ant
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/lib/tools.jar
Buildfile: build.xml does not exist!
Build failed
The build.xml does not exist part is of course expected, but the inability to locate tools.jar needs to be resolved. The strangest part for me is that according to the error message, it is actually looking for it in the JRE installation location.
Since ant itself is just a shell script, I modified it to print out a little more information by adding the following lines to the end of the file so that it looks like:
echo Running $ant_exec_command $ant_exec_args
echo JAVA_HOME = $JAVA_HOME
echo JAVACMD = $JAVACMD
echo CLASSPATH = $CLASSPATH
echo LOCALCLASSPATH = $LOCALCLASSPATH
echo ANT_HOME = $ANT_HOME
echo ANT_LIB = $ANT_LIB
eval "$ant_exec_command $ant_exec_args"
Now the output is:
$ /local/apps/ant/apache-ant-1.10.4/bin/ant
JAVA_HOME is /local/apps/openJDK8/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64
Running exec "$JAVACMD" -classpath "$LOCALCLASSPATH" -Dant.home="$ANT_HOME" -Dant.library.dir="$ANT_LIB" org.apache.tools.ant.launch.Launcher -cp "$CLASSPATH"
JAVA_HOME = /local/apps/openJDK8/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64
JAVACMD = /local/apps/openJDK8/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64/bin/java
CLASSPATH =
LOCALCLASSPATH = /local/apps/ant/apache-ant-1.10.4/lib/ant-launcher.jar
ANT_HOME = /local/apps/ant/apache-ant-1.10.4
ANT_LIB = /local/apps/ant/apache-ant-1.10.4/lib
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/lib/tools.jar
Buildfile: build.xml does not exist!
Build failed
So JAVA_HOME is clearly set. I can even verify further that ant is actually using the JAVA_HOME value that I set for at least some things because if I remove all of those links I created in my JDK install, it will complain that it can't find libjava.so.
So ant is clearly using my JDK install for at least a little bit, but still looking in the old JRE install for tools.jar.
Any ideas on what is going on?
Figured it out :)
This fix still feels a little more like a workaround than an actual fix, so if someone else has a better solution, I'd be interested to hear it.
I've browsed through the ant source code a bit and discovered that ant has a --launchdiag property which is helpful. Running with that gave me:
/local/apps/openJDK8/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64/bin/java -classpath /local/apps/ant/apache-ant-1.10.4/lib/ant-launcher.jar -Dant.home=/local/apps/ant/apache-ant-1.10.4 -Dant.library.dir=/local/apps/ant/apache-ant-1.10.4/lib org.apache.tools.ant.launch.Launcher --launchdiag
Launcher JAR= "/local/apps/ant/apache-ant-1.10.4/lib/ant-launcher.jar"
Launcher JAR directory= "/local/apps/ant/apache-ant-1.10.4/lib"
java.home= "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/jre"
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/lib/tools.jar
tools.jar= "null"
Setting "java.class.path" to "/local/apps/ant/apache-ant-1.10.4/lib/ant-launcher.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-antlr.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-swing.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-testutil.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-apache-xalan2.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-junitlauncher.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-xz.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-junit.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-apache-log4j.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-javamail.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-apache-bsf.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-apache-resolver.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-apache-oro.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-apache-bcel.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-jai.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-jsch.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-jmf.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-commons-logging.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-launcher.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-jdepend.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-commons-net.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-netrexx.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-junit4.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-apache-regexp.jar"
Buildfile: build.xml does not exist!
Build failed
In the code I found that that java.home property comes from System.getProperty("java.home") which apparently is not the same thing as JAVA_HOME
By adding -Djava.home=$JAVA_HOME I was able to get it working

Red Hat Linux Enterprise 5.7 remove Java

I need to uninstall Java jdk1.6.0.27 from RHEL 5.7 and then install another version jre-7u40-linux-x64.rpm.
The firs thing I did was to find out the current java version installed using the
java -version command and the output is "java version "1.6.0_27"".
After that I tried to check the previews version of java with the command:
rpm -qi jdk
The output is "package jdk is not installed"
After installing the package jre-7u40-linux-x64.rpm in the /usr/java directory there are two java packages.
The output of the ls command on /usr/java is:
default jdk1.6.0_27 jre1.7.0_40 jre-7u40-linux-x64.rpm latest.
when I run the command "alternatives --config java" the output is:
*+ 1 /usr/java/latest/bin/java
I am new to RHEL and I need some help to understand the situation.
To conclude I need some help to remove the previews jdk1.6.0.27 and to install jre1.7.0_40.
Thank you in advance for your help!
Best regards,
Claudio
First, find out your real java executable. Start with
which java
This is going to give you some response such as:
/usr/bin/java
Next, do
ls -l /usr/bin/java
(Or whatever it returned).
It will probably write something like:
/usr/bin/java -> /etc/alternatives/java
Do the same for whatever is pointed to by the arrow, until finally, when you do ls -l on it, there is no arrow.
Then, for that particular file, find out which rpm provides it by using
rpm -q -f <full path of the file you found>
It should tell you which package it belongs to, and then you can uninstall that.
However, if the rpm command returns The file ... is not owned by..., then your Java has not been installed using an rpm. It may have been installed manually by someone in the past.
This makes uninstalling it a lot more problematic.
If you haven't found your answer:
leave old java where it is, don't even bother with it
install new version with: rpm -ivh /root/jdk-7u40-linux-x64.rpm
deactivate old java
export new version
Deactivating old java (note entering hashtags before every line, manual installation required editing of profile, so edit it one more):
vi /etc/profile
#JAVA_HOME=/usr/java/jdk1.6.0_27
#export JAVA_HOME
#PATH=$JAVA_HOME/bin:$PATH
#export PATH
Exporting nev version (note adding new lines in profile followed after old entries):
export JAVA_HOME=/usr/java/latest
export JRE_HOME=$JAVA_HOME/jre
export J2RE_HOME=$JAVA_HOME/jre
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$J2RE_HOME/bin:$PATH
Check nev version with standard command for checking of installed sw.
Hope this suits your needs.
Just wondering: you're trying to prepare BFBOX for acceptance? Just courious! If you want more info please send me an email, ok?

Unable to run threaded java jar file on Mac OS X 10.6.8 with Java 1.7.0.45 using pacifist

I have installed Java 1.7.0_45 on Mac OS X 10.6.8 using Pacifist [http://www.charlessoft.com/] however I am unable to run a jar file which I have downloaded. The jar file is a threaded application.
The error message I am getting is:
java -jar context.jar
2013-10-31 14:14:41.898 java[330:a07] *** NSInvocation: warning: object 0x109356390 of class 'ThreadUtilities' does not implement methodSignatureForSelector: -- trouble ahead
2013-10-31 14:14:41.900 java[330:a07] *** NSInvocation: warning: object 0x109356390 of class 'ThreadUtilities' does not implement doesNotRecognizeSelector: -- abort
Trace/BPT trap
Is there anyway I can run the jar. I have set the JAVA_HOME path properly and java -version is showing 1.7.0_45 as the version.
The same application works properly on Windows Java 1.7.0_45 and also on Linux Java 1.7.
The web search for the solution and the given keywords return very few results and none of them have any specific solution in it. I am new to mac so I am not fully able to understand the issue.
Alternatively, is there anyway I can run Java from folder in Mac like I can do in windows and Linux by just extracting the Java contents and changing the JAVA_HOME. If that is possible then I should be able to run my JAR.
I had kind of same problem while installing an application through jar file, my Java was not detected by the jar application installer,
Over here I see that one of the method is not accessible, could be a same problem. But I am not very sure of it.
make sure you have rt.jar in your JAVA_HOME/jre/lib/ folder
In case you don't have then you are required to have it through the process of creation of symbolic link.
In the command below replace your_java_version with proper version matching your requirement.
sudo mkdir -p /System/Library/Frameworks/JavaVM.framework/Versions/<your_java_version>/Home/jre/lib
Go into the directory:
cd /System/Library/Frameworks/JavaVM.framework/Versions/<your_java_version>/Home/jre/lib/
Create symbolic link :
sudo ln -s ../../../Classes/classes.jar rt.jar
Hope this solves your problem.
I get the exact same problem with MacOS 10.6.8 and JDK 7. In order to run the jar I had to use the System JRE which is 1.6.x (In my case I wanted to install Squirrel
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -jar >squirrel-sql-3.6-MACOSX-install.jar

Unrecognized option: - Could not create the Java virtual machine

I am trying to run my .jar file on a linux server.
These are the commands I'm running:
JAVA_HOME=/app/local/opt/jdk/packages/jdk1.6.0_30/
export PATH=$JAVA_HOME/bin:$PATH
cd folder
nohup java -jar program.jar &
When ran on Friday, this was working perfectly. However, today I am getting:
Unrecognised option: - Could not create the Java virtual machine.
In my nohup.out
If I run java -v after setting the path I get the same problem. Can anyone suggest anything? Really confused about this.
Thanks for any help on this.
Usually, when we get this kind of exception ("Unrecognised option" which causes the "Could not create the Java virtual machine"), the JVM displays the unrecognized option, like this:
Unrecognised option: -[option details] Could not create the Java virtual machine.
the fact that you have no details makes it seem as though you just have a space (" ") in your command.
Take a look again to make sure.
I've got this failure running maven on Win10 where the pom.xml is located in a folder named something like C:\dir\OneDrive - bar\workspace\project.
Moving the project to a different folder solved it.
First of all, there is no -v option on the java command.
(Reference: http://docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html ... Java 6 version ... 'cos that is what you are using. Try java -help for the short list of options.)
So it is expected for java -v to fail.
As an experiment I tried this (with an OpenJDK Java 8 JDK on Fedora 22):
$ java -foop
Unrecognized option: -foop
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
$
As you can see, the "unrecognized option" message tells me what option it doesn't understand. Looking at the message in your question, we see that it is saying it is "-". That doesn't appear to match the command line in your question, but on the other hand the command line in your question does not have any invalid options.
Another possibility, I guess, is that you have a shell alias called java. That would take precedence over any commands on the shell's command path.
The other thing is that you are running an ancient version of Java. Java 6 has passed end-of-life, and the last publicly released version is update 45. You are running update 30 which was released in December 2011. There have been LOTS of security patches since then. I'd recommend upgrading to Java 8 ... and making sure that you keep it up to date.
for java 8 run 'java -version'
for java 9 or 9+ run 'java --version'
Had the same issue under Linux/Ubuntu 20.04.
I created a bash to run my jar and used some variables in the file
# This line below shows the error
$JAVA_PATH "-jar $JVM_ARGS $JAR_PATH"
# This line below runs without issue
$JAVA_PATH "-jar" $JVM_ARGS $JAR_PATH $SB_ARGS
I don't know why it works after using double quotes for the "-jar" option only, I think it's something to do with UNIX systems.

java.lang.NoClassDefFoundError: Could not initialize class java.awt.Component

When I run MATLAB install script in Ubuntu, I get the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class java.awt.Component
longer output is available here
I know that it's a Java problem and could potentially be fixed by changing the classpath or something like that but I don't exactly know how.
Any Ideas?
For me this error was fixed when I installed the JRE on my system:
apt-get install default-jre
on Ubuntu 12.04, instead of having MATLAB use its own.
I've been battling this problem for the whole evening as well but I stumbled onto a solution that works for me at least.
After trying to install using the silent installer I got a different error with a bit more information. It turned out that a library was missing (libXtst.so.6). I was able to install that on my Ubuntu system with:
apt-get install libxtst6
After that I tried running the GUI installer (over X forwarding) and it looks like it's going to work now.
For MATLAB R2012a Student Edition, in Ubuntu 14.04, I had to install these prerequisites first:
sudo apt-get install default-jre libxtst6:i386 libXext6:i386 libxi6:i386 libncurses5:i386 libxt6:i386 libxpm4:i386 libxmu6:i386 libxp6:i386
Next I installed/activated per MATLAB's instructions (sudo ./install). I answered "yes" when the installer asked to add a symbolic link in /usr/local/bin/
Finally, when launching MATLAB, I have to specify that it run in 32-bit mode:
matlab -glnx86
I assembled those steps from this answer: https://askubuntu.com/questions/363878/how-to-install-32-bit-matlab-in-ubuntu-64-bit
and the Ubuntu MATLAB guide:
https://help.ubuntu.com/community/MATLAB
Optional
I didn't want to type the -glnx86 option each time I launch MATLAB, so I replaced the matlab symbolic link in /usr/local/bin/ with a script that automatically specifies the -glnx86 option:
ls -l /usr/local/bin/matlab #note the destination of the symbolic link
sudo mv /usr/local/bin/matlab /usr/local/bin/matlab.bak
#ensure the first path below matches your symbolic link's destination
echo '/usr/local/MATLAB/R2012a_Student/bin/matlab -glnx86 "$#"' | sudo tee /usr/local/bin/matlab
sudo chmod +x /usr/local/bin/matlab
With that, I can type 'matlab' and it launches properly. (The "$#" in the script forwards all input arguments to matlab.) There's probably a more elegant way to accomplish this, but it worked.
I also encountered a "/lib/libc.so.6: not found" error on matlab startup, which I fixed by following this answer.
Installing gnome (sudo apt-get install gnome) fixed this problem for me. I'm sure this was total overkill, but the required libraries are now available.

Categories