Will GWT2.2.1 support java7? - java

I am using java 6 with GWT2.2.1, but the current requirement is to upgrade java from java 6 to Java 7. Is it possible to upgrade?
Your help will be appreciated.

Java 7 support was added in GWT 2.6.0. On the server side, you can use whatever Java version you like. However on the client side, you won't be able to use Java 7 features with GWT <2.6.0. You can use a Java 7 (or even 8) JDK to compile your project, just force it to use Java 6 (and of course, don't use features from Java >6 in your client side code), for example, using -sourceLevel 6.

Related

Does Android Studio 3 support Java 9 for Android development? If so, what features of Java 9 are supported?

I'm going to install Android Studio 3 in order to develop an Android application.
I'd like to know if it is possible to use Java 9 for Android development? If so, does it support all of the Java 9 features?
As far as I know, the IDE itself supports Java 9. This means you can write a Java 9 desktop program, or run the IDE with JDK 9.
However, Android itself does not support Java 9 (yet). You can still download JDK 9, although I have seen some questions on problems related to Android Studio and Java 9. Personally, I have Java 9 and Android Studio runs without problems.
The Android SDK is the development kit you'll be dealing with, and with source compatibility you'll get language features similar to Java 6, 7, or 8, depending on your settings. So you can download JDK 9 and use that most likely without issues, but you can't use any of the language features in any Android apps.
As for differences between the JDK and the Android SDK, you should read this. Android currently supports a subset of Java 8 features, but not everything. It might never support everything, or leave out some parts of Java 8, even if it later supports some parts on Java 9 or higher.
UPDATE: as of https://jakewharton.com/androids-java-8-support/, it seems like this should almost work by now (as well as for Java 9, 10, 11, and 12). Or just use Kotlin.
To help the last steps along, you can star the issue.
As of now, the Android SDK does not even support java 8 completely:
Android Studio 3.0 and later supports all Java 7 language features and a subset of Java 8 language features that vary by platform version. This page describes the Java 8 language features you can use, how to properly configure your project to use them, and any known issues you may encounter. [emphases mine]
That probably needs to be supported completely before Java 9 is approached.
Just tried to do it with Ubuntu 18.04 which uses Java 10 already. You run into tons of problems from invalid java certificates to extra warnings on gradle invocations etc. It's a mess and hopefully solved soon, you will find solutions to every problem via google but it's more easy to install Java 8 instead.
I have no idea about using the language itself inside Android application code, because i'm a full NDK C++ programmer and only use the toolchain which contains many java programs.

Steps to Migrate Code from Java 6 to Java 7 using eclipse

I have the existing codebase which runs on java6, but the current requirement is to upgrade the Java from java6 to java 7, Can anyone please let me know the steps, how can i upgrade it using eclipse(because i am using eclipse as IDE)?.
Upgrading code requires almost nothing, as Java 7 is backwards compatible with Java 6 except for a few things, mostly behavioral and in the standard library. And as said here, it should mostly just work:
What do I need to do?
Option 1 – “Just run”
Upgrading your eclipse project has been asked and answered several times, like here.

Should I keep compiling against older versions of Java?

Since the release of Java 8, I found myself slowly becoming dependent on Java 8-specific features (ex. lambda statements) on a library project that I have just started.
I have seen many other projects which, to this day, still build against Java 7, or even Java 6, causing me to second-guess myself.
Is it a good idea to immediately start building against the newest version of Java, or should I still use older versions?
Note that unlike those other projects that have started back when Java 6/7 was the newest version, mine was started recently when Java 8 is the newest.
There are two reasons I can think of that would require staying with a pre-Java 8 JVM:
You are writing a library that is being used by a large group of people outside your organization who are still stuck on a pre-Java 8 JVM. If you use the latest and greatest JVM, they won't be able to use your product anymore.
You are dependent on a 3rd party library that has not upgraded to Java 8 and breaks on Java 8.
Since you mentioned this is a new project, #1 is unlikely. Even if you plan on having external users, if it's a new project, requiring the latest version of the JVM isn't really an issue.
Number 2 is also getting more and more unlikely as the more popular 3rd party libraries have released updates to work on Java 8. Even the few stragglers are usually OK working on Java 8. For example I use an ancient version of hibernate with Java 8. I just don't use any Java 8 features in any mapped fields/entities.
Java 8 denotes a major change to the language since Java 5 (or perhaps its inception). If you are targeting specifically the changed language parts (which I guess you claim) then making it usable only by Java 8+ runtime makes sense.
When Java 5 occurred 10 years ago and you wanted to use all the new features introduced at the time (e.g. foreach statement, Enums etc.) into your own library development, what would you have done? I believe you would have made your library require Java 5 at the minimum. If you agree with that, then that (sound) logic applies consistently to your present situation as well.
For server side application, possibly a version or two prior to the current version as suggested by EJP.
On the client side however, I don't see any point in trying to support older Java versions. The JRE has been auto-updating since at least Java 6. It has gotten to the point where Java Web Start launched applications cannot specify an earlier than current JRE. Or rather, it can specify any JRE it chooses in the launch file, but that will be ignored in favor of the latest version installed on the user's computer.

Why is Java 8 JDK recommended for GlassFish 4.1?

On the GlassFish homepage it is stated that
Java EE 7 requires JDK 7 or above, JDK 8 u20 or above is recommended for GlassFish 4.1.
So I am wondering, why it is recommended to use it under the JDK 8, as GlassFish 4.1 is a Java EE 7 application server?
Is it just because that I will be able to use the new Java 8 functionalities? Or are there deeper reasons for this like stability, know bugs etc.
So does the GlassFish really runs better on the JDK 8 than on the JDK 7, or may I ignore this statement and just install it under JDK 7, if I do not use the new functionalities provided under Java SE 8?
So I am wondering, why it is recommended to use it under the JDK 8, as
GlassFish 4.1 is a Java EE 7 application server?
I guess they just recommend to use the newest compatible non-beta Java version which in this case is Java 8. The Java EE specs version (in this case Java EE 7) which is implemented by Glassfish 4 and the JDK version which is required (or which can be used) to run the server are two different things.
Also note that Java 7 has its EOL (End of Life) in April, 2015. There will be no further updates for Java 7 so at some point you'll have to switch to Java 8 anyway.
Is it just because that I will be able to use the new Java 8
functionalities?
This could be one reason for you to use JDK 8.
Or are there deeper reasons for this like stability, know bugs etc.
I guess there may be some bugs in JDK 7 which are fixed or do not occur in JDK 8, but this shouldn't be anything critical. In terms of stability I think the values are similar when not the same.
So does the GlassFish really runs better on the JDK 8 than on the JDK
7, or may I ignore this statement and just install it under JDK 7, if
I do not use the new functionalities provided under Java SE 8?
I wouldn't say that Glassfish runs better, but I would also recommend to use the latest compatible Java version. But you can currently also safely ignore the statement and use JDK 7.
For some additional information, this spring.io blog post contains a nice summary about Java 8 in enterprise projects and with various application servers.
One reason that was understood for GF to recommend using Java 8 is to leverage on new functionality it offers, such as SNI support for example. However, GF itself is not yet making full use of it.

How to use java 6 features in a java 5 environment

I am facing an strange issue. I developed java web app in java 6 and when I hosted it on server, its shows error since its java 5 server. I have used annotations, hibernate, rest API in my code and now I want to transform my code with java 5 environment.
is it possible to do so? if yes HOW? Or is there any other workaround for this problem? Please let me know.
#all: This is the error i am getting:
I am not sure what your build process is but you need to compile your code for a specific target like java 1.5.
If you are using javac from the command line look at the -target switch
If you are using ant then look at the target property.
You will run into problems if you are using java 1.6 specific libraries. You will know this when you try and run your code/webapp.
I hope this helps.
You'll have to look at the individual errors and figure out what is missing.
The JPA annotations were already part of Java EE 5, so if "hibernate" is causing problems, it either means you are not in fact running on Java EE 5, or you're using hibernate-specific annotations. The REST annotations were indeed added in Java EE 6, but can be used in a Java EE 5 environment relatively easily by adding a JAR with the API as well as the implementation (e.g. Apache Jersey) to the app's class path.
BTW, there's some confusion here concerning Java SE vs. Java EE. You're clearly talking about Java EE features, but there is a big difference between Java SE (which most people think about when you just say "Java") and Java EE.
From your post, it seems you're using Java EE 6 features in a Java EE 5 environment. If your app. server doesn't support such features at its core level, such as sing Servlet 3.0 features in a Servlet 2.5 environment, then you're out of luck.
However, when using features that are libraries, like Hibernate, you can get away using it in a Java EE 5 environment.
Java 6 as a language remains the same as Java 5, however, libraries have changed. Likewise, using JRE classes and methods that are in 6, won't work in 5.
Update: from your screenshot, I see that you're using Java 6 compiled classes on an older version of Tomcat. Compile them for Java 5.
You are trying to run classes compiled against Java 6 on Java 5 (Tomcat 5.x uses Java 5).
You can upgrade to Java 6.
You can compile the classes to be Java 5 compatible by using "-target" argument to javac but this option is not going to help as the problem is occuring with the servlet api. JEE6 requires Java 6.

Categories

Resources