I compiled a Servlet with java 15 and tried to run it with Tomcat 10 but got the error:
"java.lang.UnsupportedClassVersionError: Servlet1 has been compiled by a more recent version of the Java Runtime"
Looking at the Tomcat Properties I noticed Tomcat uses Java 8 that is installed also on my PC.
So I went to the Tomcat Properties under the Java tab and put down jdk-15.0.1\bin\jvm.dll
-> Tomcat didn't start anymore.
I noticed that in the same properties under the Java tab, there is "Java Classpath" but it's value was
Tomcat-Dir\bin\bootstrap.jar (I think). Then I changed this to jdk-15.0.1\bin (and variations thereof).
Now to my problem - Tomcat doesn't start anymore "ClassNotFoundException ... Bootstrap" I can change back the path to the JVM by checking "Use default", but I don't remember exactly the path under "Java Classpath". Can someone tell me what the default value needs to be here for Tomcat10. I would like to at least be able to start Tomcat again.
I'm talking about this Tab in the Tomcat properties
The problem you are describing (immediate service start failure, nothing in Tomcat's logs and a short line in commons-daemon.log) happens when there is a mismatch between the architecture of the Procrun service application (installed as bin\tomcat10.exe in your Tomcat installation) and the architecture of the jvm.dll: a 32-bit executable cannot load a 64-bit library and viceversa.
You can confirm it with tomcat10.exe version (works only in an administrator cmd)) and java -version.
To solve this you need to download the complete Apache Commons Daemon distribution for Windows (cf. download area) and replace tomcat10.exe with the appropriate prunsrv.exe executable (there are two versions in the zip archive).
Regarding which libraries should be in Tomcat's classpath, you just need bin\bootstrap.jar and bin\tomcat-juli.jar in your server's installation folder.
Remark: The Windows MSI installer for Tomcat contains both prunsrv.exe versions, but installs only one depending on the architecture of the Java executable you choose during installation. Probably you have a 32-bit Java 8 and 64-bit Java 15. For a long time the java.com page automatically proposed the 32-bit version of Java.
Related
I recently downloaded and unziped openJdk 14
I then went to Eclipse > Java > Installed JREs and set the new jdk to be used
However after doing this I am no longer able to run my server (tomcat webapp)
I get an error from the jdk
as well as a generic error in eclipse saying it failed to start
When googling around it said to check my paths, but as far as i can tell they are correct:
(user variable)
%JAVA_HOME% = C:\JavaProgramFiles\jdk-14.0.2
(system & user variable)
Path %JAVA_HOME%\bin
Update 1 (FYI removed some path stuff as it doesnt seem relevant anymore):
thanks #KunLun
when cd'ing into the bin directory, javac -version worked. I reviewed environment variables again and this time added %JAVA_HOME%/bin to my User's Path variable (previously it was only in system path). So now javac -version works from any directory. However Eclipse still has same error when i start my server, though i do get this new msg in the console?
-Djava.endorsed.dirs=C:\JavaProgramFiles\tomcat\apache-tomcat-9.0.21\endorsed
is not supported. Endorsed standards and standalone APIs in modular
form will be supported via the concept of upgradeable modules.
The error message you quoted shows the cause of the problem. When the server instance was defined, the JVM launch arguments set for it included a reference to endorsed directories, an argument valid through Java 8, but not for Java 9 and newer. When you open the editor for your server instance from inside the Servers View, in the General Information section, Click on the Runtime Environment link and change the JRE explicitly to a Java 8 version. The server should then start up again.
I suddenly found that I could no longer run my own developed JAVA apps by simply double-clicking the JAR file - it reported that the main class was not found.
With trial and error I found that if I forced 32-bit JAVA 1.8.0_161 to run then things worked fine. What was running by default was 64-bit JAVA 1.9. I also found it was not using JAVA_HOME but instead was running what it found in %APPDATA%\Oracle\Java.
I tried lots of things but in the end I uninstalled the 64-bit JAVA 1.9, put the path for 1.8.0_161 in JAVA_HOME, put %JAVA_HOME%\bin in the PATH and that got me most of the way...
Now if I run java -jar <jarFileName.jar> then my program runs just fine, but if I attempt to run the jar file by double clicking on it then it still could not load the main class.
Windows 10 default programs for JAR files says Java(TM) Platform SE Binary - tried forcibly changing this to point to the java.exe for 1.8.0_161 but that still doesn't work.
The JAVA Settings Console doesn't look like the ones in various web queries - I think it changed with 64-bit JAVA.
So I suspect my system is no longer properly configured.
How do I fixup the configuration to get back to where I can simply double click a JAR file in order to run it.
Best Regards
SteveM
I want to run my app only with particular JRE 1.7 version. If the client has lower versions of JRE installed, I want to auto-install the JRE 1.7 before launching the app via JNLP file.
I have the following line in my JNLP file ...
j2se version="1.7+" href="http://java.sun.com/products/autodl/j2se
But, when I launch the application with JRE6, I am getting the error ...
"The application has requested a version of the JRE (version 1.7+) that currently is not locally installed. Java Web Start is unable to automatically download and install the requested version. This JRE must be installed manually."
what changes are required in the JNLP file to auto download and install a required JRE 1.7 version on the client machine.
Since the "flag as duplicate" function, no matter what subset of the target title I enter in the search box, does not offer the following question, here it is as answer:
See Java Web Start is unable to automatically download and install the requested version.
In my personal view however, leaving it to the Java runtime to "upgrade" itself on demand feels risky. The Java deployment toolkit (which I think would be involved) has been found to be vulnerable more than once. I would prefer requiring admins or users to manually install the required JRE version.
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.
I am trying to bundle java as a part of a java product that should be installed silently with a single click and are having some issues:
My installation has the following requirements:
Has no be silent and require no user input or action excpect a doubleclick on the installation file (no configuration and post install steps)
Has to setup java so that JAVA_HOME points to a Java SE installation with a server jvm
Is this at all possible to do this on a win32 system with sun java installers? I know that by default the jre does not contian a server jvm. But even when installing the jdk the public jre which is installed (and mapped to JAVA_HOME) does not contain a server jvm. In sun own README file (Sun README) they suggest copying the files:
jre\bin\server\
On Microsoft Windows platforms, the JDK includes both
the Java HotSpot(TM) Server VM and Java HotSpot Client VM.
However, the Java SE Runtime Environment for Microsoft Windows
platforms includes only the Java HotSpot Client VM. Those wishing
to use the Java HotSpot Server VM with the Java SE Runtime
Environment may copy the JDK's jre\bin\server folder to a
bin\server directory in the Java SE Runtime Environment.
But this solution is difficult to automate gracefully in a silent install. There has to be a better way to do this without repackaging the entire java distrubution. Has anyone encountered the same problem and come up with a more elegant solution?
For the past years, I manage Java like this: I download the installer, install it somewhere, package all files into a ZIP and then use that ZIP file to deploy Java anywhere. The installer will leave a lot of stuff in the registry and %WinDir%, etc. which you don't really need. This also allows me to move some files around (like the bin\server\jvm.dll or security related settings).
That way, I can even embed Java inside the application directory, independent of any already installed version of Java.
Just set JAVA_HOME in a small batch script before starting your application and you're good. You can use %~dp0 to make it completely position independent (%~dp0 expands to the path leading to the batch file).
Make your own installer.
I use inno setup compiler, works well for my purpose.
If you need the registry entries, you can export them, include them in the installer, include the files, and a little change here and there and you're done. Silent installer that configures things to the exact specifications you need.
It comes with an easy to use script wizard.
I mention a specific one because it's free. Ultimately, making your own installer is the solutions.