I am trying to generate the documentation of a project written in java 7.
I have used things of java 7 like the try with resource statement, and when I try to generate the documentation of my project:
javadoc -d mydocks truckingCompany
(truckingCompany is the directory containing all java files)
I get a lot of syntax errors.If I try to compile the project using javac 1.7 I don't get all these errors.So I'm pretty sure that these errors are dued to the fact that javadoc is still using the version 1.6 of javac.How to change the version?
PS: An example of error is this:
home/ramy/Desktop/./truckingCompany/TCUtil.java:175: not a statement
catch( IOException | ClassNotFoundException | ClassCastException e)
^
All thing that are correct in Java 7.
Javadoc is not a standalone program, but a part of the java development kit (JDK) (it's included in tools.jar.) This being said, you'll need to update your runtime environment to be Java 7 instead of Java 6.
Since you're running Linux, this should be as simple as pointing /usr/bin/java to your JDK 7. java -version should return Java 7 (or similar) to indicate this is correct.
Related
I have multiple Java versions installed. I switch versions when needed.
If I use Java 8 as default, SoapUI will use it. A Popup with with this error will show then :
java.lang.UnsupportedClassVersionError: com/eviware/soapui/SoapUI has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Since the 5.6.0, SoapUI need a Java version ⩾ 9. So I want to specify the java version used by SoapUI when my default version is java 8.
Notes :
By default I mean, the version printed when : java -version is executed on the Terminal.
In the file SoapUI-5.6.0/bin/SoapUI-5.6.0 :
Uncomment the var INSTALL4J_JAVA_HOME_OVERRIDE at the beginning of the file
Assign the java home (JRE OU JDK) to INSTALL4J_JAVA_HOME_OVERRIDE
Example :
INSTALL4J_JAVA_HOME_OVERRIDE=/usr/lib/jvm/jre-11/
I leave here my solution since i lost 4 hours just to understand that if you have java 8 and you use Ubuntu, you can save the world but SoapUI 5.6.0 won't work.
So the solution is to download an older version, like 5.4.0
Don't bother looking for one if you're an Ubuntu lady/guy, just use this command:
$ wget https://s3.amazonaws.com/downloads.eviware/soapuios/5.4.0/SoapUI-5.4.0-linux-bin.tar.gz
Then unzip and untar the downloaded archive:
$ gunzip SoapUI-5.4.0-linux-bin.tar.gz
$ tar xvf SoapUI-5.4.0-linux-bin.tar
Finally start SoapUI by entering in the folder where it is installed and run:
/bin/soapui.sh
in case it helps anyone - I have java-11 alongside java-8 (with latter being the default) and SoapUI-5.6.0.
Solution: I've set the INSTALL4J_JAVA_HOME_OVERRIDE variable in SoapUI-5.6.0 to:
INSTALL4J_JAVA_HOME_OVERRIDE="/usr/lib/jvm/java-11-openjdk-amd64/"
Just use nano or gedit, etc. to modify (don't forget to use elevated permissions, if neccessary).
Best regards
C:\Users\YusufGalip\Desktop\JavaDeneme>java deneme
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: deneme has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
I got this error when i tried to run a compiled program.
It's probably compiled with a more recent version of java than the one you are attempting to use running the program. Do you have multiple versions of Java installed?
Try java -version and javac -version and compare the versions. If you use and IDE/editor where Java is configured in the settings, see that it points to the expected directory.
You've compiled your class with Java 11 (55) while you're still trying to execute/run them using Java-8(52).
Either compile the code using Java-8 or execute with Java-11.
The error clearly says that the compiler version was higher than the JVM version with which you are trying to run. That is why you are getting the error on running.
Java 8 uses major version 52
Java 11 uses major version 55
Reference:
https://en.wikipedia.org/wiki/Java_class_file#General_layout
=================
#DO THE FOLLOWING
change your path to point to a more recent version or if you are aware of the version using which the program was compiled, install the version and then execute the same command to run
1) run java -version now
2) Note down the version
3) complete the above #DO ****
4) execute 1) again
5) you should see a different or the latest version
6) run your program :) and you should be able to .... post your results
Finally I solved with your help.
There were 2 Java in my computer one of them is "Java SDK Tools 11" and the second one is "Java Runtime 8" I uninstalled the "Java Runtime 8" and it worked.Thank you for your help.
I understand the UnsupportedClassVersionError to be caused when I compile my java files in a newer version than the JVM the class file will be run on.
I'm working on a program that will run on an IBM i Series box, which is running Java 1.6. I've cross-compiled my files to use 1.5 for the source and target values. The actual command used is:
javac -source 1.5 -target 1.5 -bootclasspath C:/dev/languages/java/jdk1.5.0_22/jre/lib/rt.jar -extdirs "" -classpath "c:/dev/QIBM/ProdData/OS400/jt400/lib/*;/psmssys/java/src/com/gy/as400/common;." $(find ./com/gy/as400/bladder/install/* | grep .java)
Understand I am compiling the files on a Win 7 box running Java 1.8.0_131
Once the classes are compiled if I then run
javap -verbose
on any of the resulting classes, the Major Version shows 49which according to this wiki article should be compatible with JVM 1.5 and up.
I've tried to cross-compile to 1.4 but that would require me to rewite a significant portion of my code to not use FOR...EACH and generic lists.
What am I missing here.
Thank you #rdean400.
I got to thinking and went back through my transfer logs and found some errors had occurred moving the class from my dev box to the test box. I cleared out all the existing class files and transferred them again. This resolved the UnsupportedClassVersionError.
I am currently working on a class project with codename one and am running into issues with the built in InputStream and MediaManager classes. It keeps telling me that the feature I am attempting to use is from Java version 1.7.0_06 and to update when I am already using Java 1.8.
My error message is as follows:
java.io.IOException: This fetaure is supported from Java version
1.7.0_06, update your Java to enable this feature
My code is:
InputStream is = Display.getInstance().
getResourceAsStream(getClass(), "/"+fileName);
m = MediaManager.createMedia(is, "mp3",this);
I would post more of the error message/code but Stack overflows "indent" algorithm is messing up when I try to post the full code or error message.
The code you listed above should work for Java 5 and even before that so it's not the problem.
However you should run under Java 8 which is the minimum supported version for Codename One. Make sure your build.xml doesn't contain 1.5 references, if it does replace them all with 1.8. Also make sure the IDE's JVM is a Java 8 JVM and the language level is set to 8.
You might be using java 8 but your program is still executing on ols version. If you are using maven or ANT specify the version of java to 1.8 and if you are running through console, use below :-
http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javac.html
javac -source 1.8 -target 1.8 YourFile.java
Is it possible to use Java 7 in JDeveloper 10?
I have an application that works correctly in Java 5. I've updated the java.conf file to point to the Java 7 jdk, and I've changed the project properties to use the same Java 7 J2SE. When I try to compile, however, I get many errors similar to those below:
Error: class format error: Object.class on classpath C:\Program Files (x86)\Java\jdk1.7.0_40\jre\lib\rt.jar/java/lang/Object.class
Error: Object not found
Error: class format error: Class.class on classpath C:\Program Files (x86)\Java\jdk1.7.0_40\jre\lib\rt.jar/java/lang/Class.class
Error: Class not found
Error: class format error: String.class on classpath C:\Program Files (x86)\Java\jdk1.7.0_40\jre\lib\rt.jar/java/lang/String.class
Error: String not found
It seems to be choking on the java definitions themselves. I'm hoping I'm just missing a step somewhere.
Also, upgrading to a later version of JDeveloper is not an option. JDeveloper 12, as far as I've been able to tell, will not deploy to an OC4J instance.
No, you can not use jdk 1.7 together with jdev 10g. You have to stay with Java 5.
And yes, you can't upgrade to 11g or 12c as they don't use oc4j but Web logic Server.
one more notice from me. jdeveloper 10 does not run itself (this means jdeveloper 10g software does not start) with java 64 bit. also not with java6. However, if you successfully started jdeveloper with java 32 bit, you can use java 6 (jdk6) to compile and run your java applications. This can be done by changing the property of your project. Just add there a new java machine 64 bit (under libraries) and let the project us it.