I have a Play 2.2 app I'm using with Java 8 that I'm having trouble getting to work. The code compiles locally for me using OpenJDK 1.8, but when I try and push the code to Heroku, I get the following error, which was the error I was getting earlier locally when I was running on OpenJDK 1.7 with lambdas by accident.
java.lang.RuntimeException: Unknown constant: 18
I set system.properties to use Java 1.8 and I know that's working because it's starting up with the following text:
Play 2.x - Java app detected
-----> Installing OpenJDK 1.8...done
Is there something I'm forgetting to do to update to Java 8?
I tried updating the PATH as well as specified here but that didn't do anything.
Unknown constant: 18 most probably refers to CONSTANT_InvokeDynamic tag in the class file’s constant pool which has the value 18. This can’t be a JDK issue as even Java 7 understands that tag.
So it is an indicator for a byte code manipulation tool running in your runtime not understanding newer class files (but trying to process them despite the unknown version number). That worked with Java 7 as the invokedynamic feature exists but is not used with ordinary Java 7 class files (i.e. produced by javac).
Since you knew if you used bytecode manipulation by yourself, it must be part of a framework, i.e. you named heroku and the playframework. So you problem is not about updating the JDK but updating the frameworks to Java-8-aware versions, if such versions already exist.
As an add-on to Holger's response, here's what Heroku support had to say:
Hi,
Java 8 is still on an old pre-release due to delays on a linux distribution of OpenJDK. You can track the status of JDK 8 here:
https://github.com/heroku/heroku-buildpack-jvm-common/issues/10#issuecomment-38006175
Related
I've been working with Java for a bit now and the JDK/JRE version has given me quite a bit of trouble lately. I am developing using the Intellij IDEA IDE and it of course uses the latest version of the JDK, 14. However when I attempt to execute software compiled with JDK 14 outside the IDE, I get an error that the JRE isn't new enough to run this software. So I updated Java on my computer and another machine and attempt to run again without any success. After some digging, I tweaked my machine to use the JRE included in the JDK 14 which is compatible.
However it is kind of odd that I had to do that, one would think that the latest version of java should of been enough to run applications made with the latest version of the JDK (14). Right now Java is version 8 build 251 and says there is no newer update available. If JDK 14 is out for a while now, why would they not update the version of Java they ship?
The problem is partially solved, as only the machine I am using for development is capable of executing the created applications. Other people I've sent them to have been unable to run them, despite having the latest version of java. Also it is a pain to get the latest JDK, especially when having limited experience on how to get rid of old versions, change path point to the latest version, get the right package (open/oracle JDK) and do that for windows and several distrubutions of linux. What is going on? Did I get Java from the wrong place and everyone else as well? Why are oracle doing this and why are there no java updates since clearly there exists a newer version?
Starting with Java-11, separate JRE does not exist anymore. In other words, if you are using Java-11 or above, you should care about JDK only.
You should uninstall JRE-8 from your machine and make sure your JDK-14 bin folder in the PATH variable. Some application even requires JAVA_HOME to work and therefore you should make sure that your system has an environment variable called JAVA_HOME and its value set to the root folder of JDK-14 (i.e. one level above your JDK bin).
Q: What should my clients do to run my application compiled on JDK-14?
Ans: Your clients must install JDK-14. Also, check this thread for some alternatives.
You're confusing how IntelliJ or JDK are used on the OS. IntelliJ, now, often comes with its JDK binaries (but even this can be configured, IntelliJ can be configured to use any JDK/JRE build you'll provide to it); however, if you run your Java application out of IntelliJ, most likely you're using Java installed locally on your OS, which might be referenced via your JAVA_HOME environment variable.
I'd suggest to:
Check java -version in your shell (and hence you'll see what JVM instance your OS spins up when you run a Java application);
Check where java (on Windows, or which - on Linux) in your shell, to see all the Java binaries available on your OS.
Try to uninstall Java SE Development Kit and Java JRE(if you have both in your machine) and reinstall both again, JDK and JRE both, I am sharing my google drive link where you can find the latest version of both JDK and JRE and when you are done installing, add there bin folder path in the Environment Variables of your machine.
I have to use a software that require jre 1.3 or higher to run.( That is very software - last update is 9 years ago).
My computer is win8 x64 and I have installed jre 1.8 on it.
However the software didn't work, it show an error message: "require jre 1.3 or higher must be installed!".
Please give me a solution.
Thanks so much.
This kind of error is to my knowledge not part of the Java runtime itself. That means that some kind of version check has been incorrectly implemented by the developer.
The version of Java can be found in the system property java.runtime.version, which is a String formatted like "1.7.0_60-b19". It's likely that this string value is checked, and that the developer made a programming mistake leading to this error.
As far as I know you cannot change the java.runtime.version property, so the only way around this is to install an older version or to fix the program.
Java versions are always binary compatible with older versions up till now, which means that older .class files are supported. It is possible to code an application into a corner in such a way that it doesn't run anymore, but in that case you would not expect a smooth error message to occur.
When I said "smooth" above I meant that the application didn't crash with an exception. The grammar and the case of "jre" - if copied correctly - is another indication that this is not an exception generated within the JRE.
Earlier Java applications were sometimes directly linked with a certain Java runtime as company policy. Sad but true.
Recently I'm studying Java. I had no real troubles while building normal java files to .class and execute them, but, when I started a bit with applets I haven't been able to run anything.
Before I had started Java, as developer I had already a lot of development tools (Eclipse, Visual Studio, CodeBlocks and others). So, basically, I already had JDK but downloaded it again to get updated to 1.8.
Now, I have also JRE 8 and there are no troubles in using javac.exe and java.exe to build and execute, but, after building the .class file of applet, when I load the html page, I got an error which strongly recommends me to upgrade JRE.
Just to translate it:
Current version of Java is obsolete.
Upgrade (recommended choice)
Block
Later
If I do the update, it gets me to this page http://java.com/it/download/index.jsp), but, it's the download link of JRE 1.7. As much as I know, JDK 1.8 is not beta (it's accessible a 1.9 preview) so why shall I use 1.7? Indeed, after downloading and installing, when I try to run the applet, the message above is shown again.
Is actually possible to install JRE 1.8 on Google Chrome?
I resolved it. It wasn't easy since it wasn't a real trouble of java.
I had effectively Java 7 version 55 and Java 8 (but also 7-45 and 6). Java 8 was 64-bit while Java 7 was 32.
Google Chrome (32-bit browser) used so the last version it could use. According to Oracle, it's recommended to remove older versions of java (because of security) so I removed everything but the 8, and then switched to 64-bit browser (Chromium). I left older JDK installed for compatibility development reasons.
I installed java 8 on Lubuntu 13.10. It is pre release but it should work - JDK™ 8 Early Access Releases.
I added JDk to eclipse:
And tried wrote first java 8 version code.
This code should find the longest word.
I caught a bunch of exceptions:
for 12 line - it shows:
Multiple markers at this line
- Syntax error, parameterized types are only available if source level is 1.5 or
greater
- Resource specification not allowed here for source level below 1.7
Why does this exactly happen?
How to solve this trouble?
Eclipse JDT environment -- editors and tools -- only supports Java Syntax up to 1.7. As of today, Java 1.8 support is only available in early access releases.
Adding a JDK or JRE to Eclipse does no change the characteristics of the JDT environment, which is a highly-integrated set of tools. So, until Eclipse releases Java 1.8 support and that makes its way into your distribution, you will not be able to use the Java editor for any syntax that is unique to Java 1.8.
presently there are many application programs developed using recent versions of java.how an end user in a network having old version of Java can be able to see the output? (perspective: different classes includes in new version of Java)
For applications that have been developed using recent versions of Java, there's no solution other than having users upgrade their Java runtime to the minimum version required to run the applications.
Note that it is not only the classes in the standard Java library, but also the .class file format has changed in ways that are not backwards compatible with old Java runtimes.
If you develop an application that targets a specific JVM version / Java specification, then you will need to ensure that all future application updates remain backwards compatible with this JVM version / Java specification.
If you want are asking how to find out the version of Java you are currently running, you can execute the following on the command line:
$java -version
OK fine.. but is that the user should have java runtime environment in which it should support should all objects that were created with new versions which were not in old version.