The obvious disadvantage at the moment that I'm finding with my app (which was written in Java 7 to start with) is that most people don't have 7, and it takes a bit of effort to get it. The default Java download page at the time of writing still points to Java 6, not 7, and most of the current Linux distributions just seem to have 6 installed by default as well. Ubuntu 11.10 is the first to even have Java in its repository.
Also on the Ubuntu side of things, one thing I've noted is that even if Java 7 is installed, I haven't found a clean way to check if it's the default yet (and again, chances are it's not.) I'm just using a shell script that parses the output from update-alternatives --query java and launches it appropriately.
It was a conscious decision on my part to go with 7 because there were a number of new features in it that I could take advantage of, and by the time said app actually hits the point where I'd consider it out of alpha / beta I hope Java 7 will have gained more of a foothold then anyway!
The advantages pretty much all centre around using the added features - I've found the try with resources construct has made a lot of my code using IO stuff easier to read (no more nested try / finally's inside try / catches) and I'm using some of the extra APIs like the filewatcher API too. I also rather like the fact JComboBox and the underlying models are now generic which saves a fair bit of casting in Swing apps.
In short though, if you're not actually going to take advantage of any of the Java 7 features and you're just upgrading for the heck of it, there's little motivation to do so until Java 7 at least becomes a bit more established. It's made my code somewhat cleaner and been helpful with some of the additional libraries, but it's also caused a fair few headaches as well.
I would also consider the probability/requirement change of running your new code(java 7) in java 6 or less since some features will not compile like the following:
Strings in switch statements
try-with-resources statements
improved type inference for generic instance creation ("diamond operator")
improved exception handling (multi-catch)
Make sure the version of java used on your considered projects is not likely to be enforced before switching.
The question is really "when", not "if". If you have a pressing need for some of the new Java 7 features (doubtful) then it's obvious.
Otherwise I'd personally wait about year or so to weed out any other possible showstoppers & headaches, before seriously considering a migration production and UAT environments.
Still, you should already have an environment with Java 7 running just to get an idea of what you'll be in for. Java 6 will be retired at some point and you should be well prepared to make the transition.
发布评论
评论(5)
目前我发现我的应用程序(最初是用 Java 7 编写的)的明显缺点是大多数人没有 7,并且需要付出一些努力才能获得它。在撰写本文时,默认的 Java 下载页面 仍然指向 Java 6,而不是 7,并且大多数当前的 Linux 发行版似乎也默认安装了 6。 Ubuntu 11.10 是第一个在其存储库中包含 Java 的版本。
另外,在 Ubuntu 方面,我注意到的一件事是,即使安装了 Java 7,我还没有找到一种干净的方法来检查它是否是默认的(再说一遍,很可能不是。)我只是使用一个 shell 脚本来解析来自
update-alternatives --query java
并适当启动它。选择 7 是我有意识的决定,因为其中有许多我可以利用的新功能,而且当该应用程序实际上达到了我认为它已经脱离 alpha/beta 的程度时无论如何,我希望 Java 7 能够获得更多的立足点!
优点几乎都集中在使用添加的功能上 - 我发现 try with resources 构造使我的许多使用 IO 内容的代码更易于阅读(不再有嵌套的 try /finally 在 try / catch 中)并且我也使用一些额外的 API,例如 filewatcher API。我也很喜欢 JComboBox 和底层模型现在是通用的,这节省了 Swing 应用程序中的大量转换。
简而言之,如果您实际上并不打算利用 Java 7 的任何功能,而只是为了它而进行升级,那么在 Java 7 至少变得更加成熟之前,没有什么动力这样做。它使我的代码更加清晰,并且对一些附加库很有帮助,但它也引起了一些令人头痛的问题。
The obvious disadvantage at the moment that I'm finding with my app (which was written in Java 7 to start with) is that most people don't have 7, and it takes a bit of effort to get it. The default Java download page at the time of writing still points to Java 6, not 7, and most of the current Linux distributions just seem to have 6 installed by default as well. Ubuntu 11.10 is the first to even have Java in its repository.
Also on the Ubuntu side of things, one thing I've noted is that even if Java 7 is installed, I haven't found a clean way to check if it's the default yet (and again, chances are it's not.) I'm just using a shell script that parses the output from
update-alternatives --query java
and launches it appropriately.It was a conscious decision on my part to go with 7 because there were a number of new features in it that I could take advantage of, and by the time said app actually hits the point where I'd consider it out of alpha / beta I hope Java 7 will have gained more of a foothold then anyway!
The advantages pretty much all centre around using the added features - I've found the try with resources construct has made a lot of my code using IO stuff easier to read (no more nested try / finally's inside try / catches) and I'm using some of the extra APIs like the filewatcher API too. I also rather like the fact JComboBox and the underlying models are now generic which saves a fair bit of casting in Swing apps.
In short though, if you're not actually going to take advantage of any of the Java 7 features and you're just upgrading for the heck of it, there's little motivation to do so until Java 7 at least becomes a bit more established. It's made my code somewhat cleaner and been helpful with some of the additional libraries, but it's also caused a fair few headaches as well.
我还会考虑在 java 6 或更低版本中运行新代码(java 7)的概率/要求变化,因为某些功能不会像下面这样编译:
确保在切换之前不太可能强制执行您所考虑的项目上使用的 java 版本。
I would also consider the probability/requirement change of running your new code(java 7) in java 6 or less since some features will not compile like the following:
Make sure the version of java used on your considered projects is not likely to be enforced before switching.
问题实际上是“何时”,而不是“如果”。如果您迫切需要一些新的 Java 7 功能(值得怀疑),那么这是显而易见的。
否则,我个人会等待大约一年左右的时间来淘汰任何其他可能的搅局者和其他人。在认真考虑迁移生产和 UAT 环境之前。
不过,您应该已经拥有一个运行 Java 7 的环境,只是为了了解您将要做什么。 Java 6 将在某个时候退役,您应该做好过渡的准备。
The question is really "when", not "if". If you have a pressing need for some of the new Java 7 features (doubtful) then it's obvious.
Otherwise I'd personally wait about year or so to weed out any other possible showstoppers & headaches, before seriously considering a migration production and UAT environments.
Still, you should already have an environment with Java 7 running just to get an idea of what you'll be in for. Java 6 will be retired at some point and you should be well prepared to make the transition.
我认为大多数情况下您都会顺利进行迁移,尽管您应该检查 Oracle 提供的有关 Java 1.6 和 Java 7 之间不兼容性的链接
http://www.oracle.com/technetwork/java/javase/compatibility -417013.html
像 Java 7 中的“改进的异常处理”这样的源代码级别的不兼容性很少,这可能会导致一些问题
I think mostly you will be fine with the migration, although you should check with link provided by Oracle about the incompatibilities between Java 1.6 and Java 7
http://www.oracle.com/technetwork/java/javase/compatibility-417013.html
There are few source level incompatibilities like "Improved Exception Handling" in Java 7 which could cause some problems
这是一个很好的问题,我的答案完全基于 java 7 提供的经验和新功能。
It is good question and my answer is totally based on experience and new features provided by java 7.