Having trouble starting tomcat with a different JAVA_HOME - java

I want to start my tomcat with a different java version than the "standard one". On my server java 6 is installed (java -version returns: java version "1.6.0_34")
I also downloaded a java 7 jdk and put it to /opt/oracle/7/jdk1.7.0_55/ and wanted my tomcat to run with java 7. So I added export JAVA_HOME=/opt/oracle/7/jdk1.7.0_55 to my script /etc/init.d/tomcat7.
When I try to start my tomcat via sudo /etc/init.d/tomcat7 start I get /opt/tomcat7/bin/catalina.sh: 1: eval: /opt/oracle/7/jdk1.7.0_55/bin/java: not found
But when I type ll /opt/oracle/7/jdk1.7.0_55/bin I get -rwxr-xr-x 1 root root java* So the path should be correct!?
I can't figure out why it doesn't work. Any hints appreciated. :-)
EDIT:
I probably just downloaded the wrong jdk (32 bit instead of 64)

You probably downloaded the wrong JDK. From your comments, it seems to be a 32bit JDK. If you have a 64bit Linux, then you can't load the executables.
uname -m tells you the architecture of your system. It should be i686 or i586 but probably is x86_64.

Related

Openfire server is not starting on JAVA 64 bit

i was trying to install openfire in my windows 64 bit OS, but server was not starting , and giving below error message.
which says JAVA_HOME doesn't point to 32 bit JRE,
where as in openfire site, nothing was said about 32 or 64 bit jdk version.
upon clicking ok i am getting serious of error messages,
do i need to point openfire to 32 bit jdk and jre to make it workable?
It is possible to start openfire from command line:
java -jar startup.jar
Assuming it is executed from ./lib of openfire installation dir, and you have binaries of your preferred java in system path.
The error means exactly what it said. You have either installed the wrong architecture flavor of Java / the JDK or haven't installed Java at all. If you haven't installed the 32-bit JDK yet, grab it at http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html and install it. If you already have the 32 Bit JDK, change the environment variables of your system to let JAVA_HOME point to the correct installation. Refer to https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/ for further instructions. If that doesn't help, deinstall every JDK inst install the 32-bit JDK from scratch.
i have downloaded zip version of openfire , which is having this issue, i have downloaded .exe version with jre bundled, which is working fine.

Tomcat 7 startup error: tcnative.dll is not valid

I use;
Windows 7 64 bit,
JAVA_HOME= JDK1.7 64 bit,
Tomcat-7 64 bit version
When I start tomcat from commandline it works ok, but when I use it within IntelliJ I get this error;
java.lang.UnsatisfiedLinkError: tcnative-1 (.\tcnative-1.dll is not a valid Win32 application.
I also point to an IBM 32bit JDK1.6 from IntelliJ in project settings, but this could not be a problem since this setup works on some other collegae's computers
I have read similar questions here, but none of them offers a solution for my case, any ideas, how can I fix this?
Here is a link which describes the problem :
Cause:
You get this message when you start Tomcat. Tomcat is looking for a shared object call tcnative (dll or so depending on the platform). If it doesn't find it, it'll revert to java libs. Either way, this shouldn't affect your application. tcnative dll is needed to address scalability in Tomcat.
Solution:
Turn down debugging level for Tomcat or
Get tcnative from http://tomcat.apache.org/native-doc/ (windows users can download the binary) and place it in your library path.
Lib path is usually: C:\Program Files\Apache Software Foundation{Apache Tomcat directory}\lib; for windows
Basically It seems that you may have an incorrect version.
Are you using multiple java on your machines if yes then try to look into environment variables for JAVA_HOME & PATH. Secondly, also paste the complete version of java and tomcat
Also run following commands at command prompt
java -version
javac -version
echo %JAVA_HOME%
And are you using MSI installer of tomcat or just a zip version of tomcat. Because in many cases MSI installer never work for some ghost reasons.

Eclipse on Mac 10.8 - Installed 1.7.0 JRE / JDK, but Eclipse won't launch

Installed Java SE 1.7.0u10 from Oracle w/ their installer package
Downloaded and unpacked Eclipse Juno (4.2.1)
Double click Eclipse purple icon and get OS X alert prompt with error message:
To open "Eclipse," you need a Java SE 6 runtime. Would you like to
install one now?
(in terminal) which java - /usr/bin/java
ls -l /usr/bin/java - /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
(in Finder) Double click eclipse alias (included when unpacked download) - Terminal launches, /Applications/Eclipse/Eclipse.app/Contents/MacOS/eclipse ; exit ; and Exclipse launches without OS X alert prompt.
I've tried modifying the Eclipse app bundle plist to point the -vm key to /System/Library/Frameworks/JavaVM.frameworks/Versions/Current/Commands/java, but I feel like I probably shouldn't have to do this.`
I'd like to know how to get Eclipse to launch by just double clicking on the Application package. It's such a small thing to bug me... :o)
The best answer is to fix the Java 7 installation as shown here :
https://stackoverflow.com/a/19594116
Simple to do and I have confirmed it works on Mavericks. With this fix, you can launch your app from the launchpad as usual. If you upgrade your JDK, you will have to reapply the fix to the new installation.
I had JDK 7 installed and I solved this issue for eclipse Kepler by running eclipse from the terminal instead of the finder.
./eclipse
Just thought to share.
Update 1
For the sake of completeness, if you want to run it from Finder as well, you can wrap the ./eclipse command into a .command file and run it from Finder (so that you don't have to open a terminal)
The following lines should do the job (don't forget to replace "your-full-eclipse-path" with the eclipse path on your machine)
#!/bin/sh
/your-full-eclipse-path/eclipse
After that, give execute permission to the eclipse.command file you just created
chmod +x eclipse.command
I found the answer over on Ask Different
It's an ugly hack, but works perfectly.
posted on this page: Mountain Lion with Java 7 only
To trick OS X to accept Java 7 instead of proposing to install Java 6 a simple symlink is enough:
sudo mkdir /System/Library/Java/JavaVirtualMachines
sudo ln -s /Library/Java/JavaVirtualMachines/1.7.0.jdk /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
Most Java Programs will run with this little hack without the need to install Java 6. OS X's Java Preferences (and maybe some others) will not as it seems to explicitly check the version of the JVM when it is started.
script above can fix my problem.
Hoping you are using 64-bit of Java SE 1.7.0 and so advising the following.
go to Eclipse->Preferences...->Java->Installed JREs
click Add...
Select Standard VM
paste /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home into JRE home
Change the JRE name to something useful like Java SE 7
Click Finish
Check the check-box next to your newly created JRE.
You would need a restart.
For what it's worth, the Eclipse team seems to have worked around it by replacing their dlopen()-based method with a CFBundleCreate()-based one: https://bugs.eclipse.org/bugs/show_bug.cgi?id=411361
In case anybody has the same problem in their code that launches Java and does not want to resort to Apple-only APIs, I found an easier work-around: before dlopen()ing $JRE_HOME/lib/server/libjvm.dylib, make sure to open dlopen() $JRE_HOME/lib/jli/libjli.dylib. Then it won't ask to install Java 6.
Can you imagine that? You have to install a JDK 1.6 to get eclipse ran properly, even if you already have jdk 1.7 installed, and set the JAVA_HOME properly.
To resolve your issue, you just need to download the jdk1.6 from http://support.apple.com/kb/DL1572?viewlocale=en_US, and install it, later you will be able to run eclipse, and you can set the JAVA_HOME to JDK1.7, and you will be able to find the JDK1.7 from eclipse "Preferences".
All these hacks does not work on mac Mavericks,
But a simple and efficient solution is found here
it worked with me like a charm.
Note: a drawback of this solution is when you check your java version using "java -version" command, it will read Java 1.6
open /Library/Java/JavaVirtualMachines/jdkXXXXX.jdk/Contents/Info.plist
settting(<string>BundledApp</string> is usefull!):
<key>JVMCapabilities</key>
<array>
  <string>JNI</string>
  <string>BundledApp</string>
  <string>WebStart</string>
  <string>Applets</string>
  <string>CommandLine</string>
</array>
I had the exact same message when setting up a new mac and trying to run eclipse 4.2.2 with only Java SE 7 installed (as part of JDK 7u17).
In order to be able to successfully launch Eclipse I had to let OSX download and install Apple's Java SE 6 runtime first before installing the latest JDK.
After installing the JDK, the command java -version correctly shows:
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
Trying to solve the problem the other way around didn't work -- i.e. installing JDK 7u17 first before installing Java SE 6 as suggested in the message.
I had the exactly same problem some days ago and I solved it today. Just installed this http://support.apple.com/kb/dl1572
And after that, when I opened the eclipse the OSX installed some java update and opening eclipse by Eclipse.app started working.
Hope it works with you too.
If you'd like to install Java 6 JDK only (no Java 7 JDK/JRE, no Java 6 JRE only), install the Apple OSX Java DMG (at time of writing, this was http://adcdownload.apple.com/Developer_Tools/java_for_os_x_2013003_developer_package/java_for_os_x_2013003_dp__11m4406.dmg).
You still won't be able to start Eclipse. Make a directory JavaVirtualMachines under /System/Library/Java. And then make an Alias of the java version folder at /Library/Java/JavaVirtualMachines and rename the alias 1.6.0.jdk and copy that alias to /System/Library/Java/JavaVirtualMachines/
After finished, you will have an Alias at /System/Library/Java/JavaVirtualMachines/1.6.0.jdk that points to the Java install directory at */Library/Java/JavaVirtualMachines/1.6.0_XX-XXX-XXX.jdk*
Install latest JDK from Sun, it installs into /Library/Java/JavaVirtualMachines/, e.g. /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk
sudo mkdir /System/Library/Java/JavaVirtualMachines
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/ /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
========= this trick used to work on Mountain Lion, but not on Maverick 10.9 somehow ============
Tried this again on Maverick, it does not work anymore. I also tried to change eclipse app plist and eclipse.ini (by adding -vm or ), does not work either.
Some people suggested that this is caused by Eclipse binary prepared using Apple 1.6 appbundler instead of Oracle java7 appbundler: Application is using Java 6 from Apple instead of Java 7 from Oracle on Mac OS X?
For now, please just type the eclipse from command line, which works fine with JAVA_HOME set to Java 7 (/usr/libexec/java_home command will tell you)
How to Make Eclipse Run on OS X 10.9 Mavericks
Attempting to launch various Eclipse versions after the Mavericks upgrade pops up a dialog with this message:
To open "Eclipse.app" you need a Java SE 6 runtime. Would you like to install one now?
It turns out that Java 7 is disabled by default in OS X 10.9.
This is easily verified as follows:
$ java --version
No Java runtime present, requesting install.
The solution is to install the latest supported Java version from Apple support: Java for OS X 2013-005 (http://support.apple.com/kb/DL1572)
As of 10/15/13 this would be Java SE 6 1.6.0_65.
Post Date: Oct 15, 2013
File Size: 63.98 MB
After the install, Eclipse will run as expected from the Dock, the Finder, or the Terminal without any tricks, hacks, or work-arounds.
I wanted to run Eclipse itself with Java 7. As I have a couple of plugins that do not work without it. For me neither solution worked for 10.9, but I found a workaround. The main idea is that you start eclipse with java -jar launcher.jar and provide a couple of magic properties and then it starts. This guy provided the command line script in comments that works for me:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=411361#c25
I found the same problem (Mac OS X 10.9.2, Java 1.7.0_53b13, Eclipse Kepler). The workaround was quite easy:
Find the executable in Finder (CMD+Click on Eclipse's icon in the Dock)
Remove the icon from the Dock
CTRL+Click on the executable in Finder
ALT+Open (to allow the execution of a non-signed application)
Eclipse opens normally and without any problem
Re-dragged the program onto the Dock
I had this problem and found that I did not have JDK installed on my Mac. Once I did that, Eclipse starts normally.
I had same problem.
First of all ; JDK(java development Kit) and JRE(Java Runtime Environment) are different things. It was confused by people
In order to install eclipse yo should install latest JDK . So
Visit
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Download suitable version for your mac
You can check your version now ; it won't be 1.6 anymore
Try to install eclipse again , see it works.
Good luck!..

which java version does tomcat use

I have set the JAVA_HOME to C:\Program Files\Java\jdk1.5.0_11
I have set the Classpath to C:\Program Files\Java\jre1.5.0_11
I have set the path to
C:\Ruby193\bin;C:\XEClient\bin;
F:\oracle\product\10.2.0\db_2\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
C:\Program Files\Java\jdk1.6.0_17\bin;
C:\Program Files\jEdit;C:\Program Files\TortoiseSVN\bin;
C:\Program Files\Microsoft SQL Server\90\Tools\binn\
Now my question is, what version of java does the tomcat run on?
The tomcat console writes the whole 'path'
and the cmd says it is java version 7 currently running in the system.
Someone please help me out.. I have java 5,6,7 versions installed in my system and also tomcat 5,6,7.
Now what is the tomcat's java version and the system's java version???
You can look up the Java version Tomcat is really running with in the manager app, which is installed by default. Go to http://hostname:8080/manager/html (replace hostname by hostname or localhost), scroll to the bottom, there you will find "JVM Version".
Which JVM is selected depends a lot on the OS and way to install, maybe http://tomcat.apache.org/tomcat-7.0-doc/setup.html will help.
E.g. if you are running Windows with Tomcat with the service wrapper (I would recommend this for Windows), you can set the path to the JVM directly in the tray icon -> Configure Tomcat. In the Java tab e.g. set Java Virtual Machine to "D:\java\jdk1.6.0_35\jre\bin\server\jvm.dll" (disabled "use default") or where your JVM resides -> you need to specify the complete path to the jvm.dll.
Regarding getting to know which Java the system is running on: That's difficult to answer, there isn't really one Java version that the system is running as such. E.g. for Windows there may be one Java version set in the PATH, a potentially different one in JAVA_HOME / JRE_HOME / ..., one (or more) set in the registry, a certain version plugin active in each web browser used for applets etc. You have to check in the part you are interested in. Most good Java apps will display the version used somewhere, in logs, about dialogs or so. For Firefox you can check in the add-ons / plug-ins list. A Java exe wrapper like JSmooth can search for Java in different places and choose the most suitable, e.g. the newest, not necessarily the most "exposed".
If you don't have the manager application on your server (I didn't), then you can check it like this:
ps -ef | grep tomcat
The output should list your running server:
tomcat 741 1 87 01:07 ? 00:01:15 /usr/java/default/bin/../bin/java ...
Now you know where your java is that your tomcat was executed from you can check the version like:
/usr/java/default/bin/../bin/java -version
I found this command helpful. From your tomcat install directory.
Linux
java -cp lib/catalina.jar org.apache.catalina.util.ServerInfo
Window
java.exe -cp lib\catalina.jar org.apache.catalina.util.ServerInfo
Sample output
Server version: SpringSource tc Runtime/2.0.4.RELEASE
Server built: August 3 2010 0710
Server number: 6.0.28.29
OS Name: Linux
OS Version: 2.6.18-194.11.1.el5
Architecture: i386
JVM Version: 1.6.0_21-b06
JVM Vendor: Sun Microsystems Inc.
Reference at https://confluence.atlassian.com/confkb/how-to-determine-your-version-of-tomcat-and-java-331914173.html
The java version is written in the log file right after tomcat start. Just look keyword "Java Home" in Catalina log logs\catalina.yyyy-mm-dd.log.
Nov 23, 2020 3:56:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\Program Files\Java\jre1.8.0_251
You can choose by altering catalina.bat/catalina.sh, your set up will use JAVA_HOME, unless you change setenv.bat.
just type java -version into your dos prompt to see your default java version, which programs will use unless you explicity tell them not to.
If you are running Tomcat from Eclipse, the JVM version that Tomcat will use is the one that is the checked JRE in the Installed JREs.
Example:
Check:
Bonus:
If you want to find out which Tomcat's version is compatible with which version of Java, check it out here

How to install j2sdk 1.4.2 on 64bit linux?

I have a problem with installation of java j2sdk 1.4.2 on 64bit linux (Ubuntu 10.04). Did anybody handle it?
uname -a
2.6.32-25-generic #44-Ubuntu SMP Fri Sep 17 20:05:27 UTC 2010 x86_64 GNU/Linux
I run a self-extracting file
sudo ./j2sdk-1_4_2_02-linux-i586.bin
but I get
tail: cannot open `+473' for reading:
No such file or directory
Oracle forum has no answer.
The problem is that the ubuntu tail command doesn't understand the 'tail +<>' syntax. You need to edit the file, being careful not to corrupt the content that is after the 473rd line, replacing the tail command with 'tail -n +473' instead. This should get you past this problem.
You should always prefer Ubuntu's package management system before trying to install software manually.
Is there a reason why you want to install the outdated Java version 1.4.2? It's better to install the latest Java version, which is version 6. Note that Sun Java 6 is backward compatible with 1.4.2; anything that runs on 1.4.2 will also run on Java 6.
Also note that you can use "javac -target 1.4" to ensure that the generated class files will be compatible with 1.4 JVM.
If you really have a special reason to install Sun Java 1.4.2: Ubuntu works with .deb (Debian) packages.
Try "chmod a+x ..."
is this package for 64 bit OS? how abt try to run it on a 32 bit OS?
When you run "sudo ./j2sdk-1_4_2_02-linux-i586.bin", are you really in the same path? how abt try to use absolute path.
obviously, #Jeroen Rosenberg's way is much better
you could have also temporarily replace tail command binary with a bash script, or alias or something, handling arguments the way you want :)

Categories