Java IO exception feature is supported from different Java Version - java

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

Related

Does Japser Reports work with Java9

Im having trouble using Japser Reports with Java 9.
My JasperVersions:
<dependency.version.jasper>6.5.1</dependency.version.jasper>
When trying to build my Report i get the following error Message:
An internal error occurred during: "Building report".
java.lang.UnsupportedClassVersionError: my/path/to/my/class/User 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
the Error occurrs probbably because Jasper does not Support java 9 Classes. I cant find any information on this topic, does anyone have a Idea how to write a workaround or did i do some other mistake?
EDIT:
After searching some more i realised that the problem only happens when im in the Designer in Eclipse, so it is most likely that eclipse itselve is not running in a JVM 9. I checked for the current version of java installed and it is java9, when i change the eclipse.ini file from:
-Dosgi.requiredJavaVersion=1.8
to
-Dosgi.requiredJavaVersion=1.9
i get a incompatible jvm error which says that im trying to start it with 1.8.0_161. How do i change my settings that my eclipse is acutally using my current JDK?
RESOLVED:
The error was that my Eclipse itselve only run in Java8. So my Application was building everything in Java9, like i wanted it to, but when i was inside the jasperReports Designer, the designer itselve run in java8. Thats why it crashed. The solution was to change the systemvariables and put my JavaPath over the Oracle JavaPath that for some reason had a higher priority.
Code was compiled in Java version 9 but executed in Java 8 JVM, which not necessarily works. Try compiling it in Java 8, or executing it in Java 9 JVM.

Unsure if I am using the correct version of Java for Eclipse

I am having a bit of trouble determining if I am running the correct version of Eclipse and/or Java. I am attempting to make changes to a JAXB program for work. I can't run the program and an error is generated that states
java.lang.UnsupportedClassVersionError: RunISOPaymentFileSimulator : Unsupported major.minor version 51.0
I know from doing my research using the search function this means that I need version J2SE 7.
After searching for my current version I find that I have Java 6 Standard Edition build 1.6.0.
My question is this: Is Java 6 the same thing as J2SE 6? Do I need to just update my Java version to 7 or do I need to also find the special J2SE 7?
Thanks very much!
Neither Java not J2SE is specific enough. What you need is the Java 7 JRE (Java Runtime Environment.) You probably already have it but your JAVA_HOME is set to 6. Changing your JAVA_HOME can cause issues for some applications that are written poorly so be prepared to have to switch it back.
http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html

Manage javadoc to use jdk 1.7

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.

How to use the Play Framework with Google App Engine with locally installed Java 7?

I've just downloaded the latest version of the Play Framework (1.2.3) and am using it with the latest Scala plugin (0.9.1) and the Google App Engine module (1.4).
The default application works fine locally (at localhost:9000, the default port). I've also successfully published the default application to GAE using play gae:deploy.
However, when I go to the GAE remote URL, I get the standard error message:
Error: Server Error.
The server encountered an error and could not complete your request.
If the problem persists, please report your problem and mention this error message and the query that caused it.
Here is the full stacktrace in the GAE logs: https://gist.github.com/1181257
I'm guessing the first error, the NPE, is due to something that can be easily fixed, so ignore that for now; however, note the second - critical - error, which says:
java.lang.UnsupportedClassVersionError: helpers/CheatSheetHelper$1 : Unsupported major.minor version 51.0
51.0 is (I think) the class version that the Java 7 compiler generates. Now, my question is simple:
How to force the Play Framework and its Scala plugin to compile the classes for GAE publishing using the -target 1.6 and -source 1.6 options, so that the output classes are 1.6 compatible, instead of the defaults, which make the local Java 7 installation generate 1.7 output classes?
Thanks.
[edit] As for the NPE, it seems that it's not thrown on Play 1.2.1 and the 0.9 version of the Scala plugin: Play framework with scala and GAE - again, this is just a side issue, the primary issue (getting Java 7 working) still stands. I've created a ticket for this: http://play.lighthouseapp.com/projects/74274-play-scala/tickets/45-nullpointerexception-on-google-app-engine
To get java 7 to work currently, you have to use the following configuration in your application.confirm file
java.source=1.6
See here for more details - VerifyError; Expecting a stack map frame in method controllers.Secure$Security.authentify
Java 7 is fully supported for Play 1.2.4 RC3 - give it a try and see if it solves your issues.
I just ran into the same issue. I'm running Java 7 and don't want to have all my other Java stuff run on 6 again. So, what I did was dump a copy of JDK 6 in a directory and then made a simple bash script to set the proper environment vars and call play. I then symlinked that script as "play" on my path. Now when play gets called it has a JDK 6 environment to run under without having to change everything else on the machine.
...less than ideal, but it works well enough and keeps everything clean.

Running a developed Program with java 1.2 (SSFnet) with java 8

I am trying to build SSFnet simulator which is a network simulator developed in Java JDK 1.2.
After downloading it, I am trying to build it, but I got errors such as some unsafe functions has been used or some unsafe input has been used in your program etc. The problem is that I am using java 8 to run a program which has been developed with Java 1.2. Specifically, I get this error:
error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
and
(use -source 1.4 or lower to use 'enum' as an identifier)
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
5 errors
Makefile:114: recipe for target 'SSF.OS' failed
make: *** [SSF.OS] Error 1
I tried to install java JDK 1.2 on my machine, but I get fragmentation fault kernel dumped error
I do not know if this is possible to run a program which has been developed with Java 1.2 with Java 8 or not and how can I handle this unsafe errors. I have no idea what should I do!
I haven't tried it, but javac -source 1.2 should do the trick.
According to the docs you should be able to use "source 1.2" in the javac 1.6 compiler.
https://docs.oracle.com/javase/6/docs/technotes/tools/windows/javac.html

Categories