Java JDK 1.4 和 JDK1.6 有什么区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3003346/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
what is difference between JDK 1.4 and JDK1.6
提问by Vipin Nemade
I have created the project using the JDK 1.4. Now I want to use JDK 1.6 version in my project. for this what steps are required.Means I want to know the what changes is require in code to get a JDK 1.6 feature.Basically I am talking about the features that is added in JDK 1.6. If any one list out that changes it is very helpful.
我已经使用 JDK 1.4 创建了该项目。现在我想在我的项目中使用 JDK 1.6 版本。为此需要哪些步骤。意思是我想知道代码中需要进行哪些更改才能获得 JDK 1.6 功能。基本上我在谈论 JDK 1.6 中添加的功能。如果有人列出了更改,那将非常有帮助。
Thanks in advance..............................
提前致谢..............................
采纳答案by Andreas Dolk
To my opinion, the four most prominent enhancements since Java 1.4.2 are
在我看来,自 Java 1.4.2 以来最突出的四个增强是
- Generics
- enums
- enhanced for-loop and
- Annotations
- 泛型
- 枚举
- 增强的 for 循环和
- 注释
There are a lot of additional classes and API enhancements, but if you want to 'upgrade' your code, I'd suggest to start your refactoring with using generics and replacing standard for loops by enhanced for loops. Both can be done without major code changes, clean up the code (you can delete a lot of lines of code) and improve readability. And using generics might reveal some hidden bugs ;)
有很多额外的类和 API 增强功能,但是如果您想“升级”您的代码,我建议您从使用泛型开始重构,并通过增强的 for 循环替换标准 for 循环。两者都可以在不进行重大代码更改的情况下完成,清理代码(可以删除很多代码行)并提高可读性。使用泛型可能会揭示一些隐藏的错误;)
回答by bdhar
回答by AjayR
There are so many changes added in 6.0.
6.0 中添加了如此多的更改。
However all your 1.4 code will run smoothly. For further reference about the version please see the following link
但是,您的所有 1.4 代码都将顺利运行。有关版本的进一步参考,请参阅以下链接
http://en.wikipedia.org/wiki/Java_version_history#Java_SE_6_.28December_11.2C_2006.29
http://en.wikipedia.org/wiki/Java_version_history#Java_SE_6_.28December_11.2C_2006.29
Hope it helps.
希望能帮助到你。
回答by Incognito
Better to see differences between 1.4 and 1.5 and then between 1.5 and 1.6. You can check new features in each version on official web site, but below is a little chronology ...
最好先查看 1.4 和 1.5 之间的差异,然后再查看 1.5 和 1.6 之间的差异。您可以在官方网站上查看每个版本的新功能,但下面是一个小年表......
JDK 1.0 (january 23, 1996) oak
JDK 1.0(1996 年 1 月 23 日)
- Initial release
- 初始发行
JDK 1.1 (february 19, 1997)
JDK 1.1(1997 年 2 月 19 日)
- Retooling of the AWT event model
- Inner classes added to the language
- JavaBeans
- JDBC
- RMI
- AWT 事件模型的重组
- 添加到语言的内部类
- JavaBeans
- JDBC
- 风险管理信息
J2SE 1.2 (December 8, 1998) playground This and subsequent releases through J2SE 5.0 were rebranded retrospectively Java 2 & version name "J2SE" (Java 2 platform, Standard edition) replaced JDK to distinguish the base platform from J2EE (java 2 platform, enterprise edition) and J2ME (java 2 platform, micro edition).
J2SE 1.2(1998 年 12 月 8 日)操场 此版本以及通过 J2SE 5.0 的后续版本被追溯重新命名为 Java 2 和版本名称“J2SE”(Java 2 平台,标准版)取代了 JDK 以区分基础平台和 J2EE(Java 2 平台,企业版)和 J2ME(java 2 平台,微型版)。
- Strictfp keyword
- Reflection
- Swing api integration into the core classes
- JVM equipped with a jit compiler
- Java plug-in
- Java IDL
- An IDL implementation for corba interoperability
- Collections Framework
- Strictfp 关键字
- 反射
- Swing api 集成到核心类中
- 配备 jit 编译器的 JVM
- Java插件
- Java IDL
- corba 互操作性的 IDL 实现
- 集合框架
J2SE 1.3 (may 8, 2000) kestrel
J2SE 1.3(2000 年 5 月 8 日)红隼
- Hotspot jvm included
- JavaSound
- JNDI included in core libraries
- Java platform debugger architecture (jpda)
- RMI was modified to support optional compatibility with corba
- 包含热点 jvm
- JavaSound
- JNDI 包含在核心库中
- Java 平台调试器架构 (jpda)
- RMI 被修改以支持与 corba 的可选兼容性
J2SE 1.4 (february 6, 2002) merlin
J2SE 1.4(2002 年 2 月 6 日)梅林
- assert keyword
- Regular expressions
- Exception chaining (allows an exception to encapsulate original lower-level exception)
- Internet protocol version 6 (IPV6) support
- Non-blocking nio (new input/output)
- Logging API
- Image i/o api for reading and writing images in formats like jpeg and png
- Integrated XML parser and XSLT processor (JAXP)
- Integrated security and cryptography extensions (JCE, JSSE, JAAS)
- Java web start
- 断言关键字
- 常用表达
- 异常链(允许异常封装原始低级异常)
- Internet 协议版本 6 (IPV6) 支持
- 非阻塞 nio(新的输入/输出)
- 日志API
- 图像 i/o api,用于以 jpeg 和 png 等格式读取和写入图像
- 集成 XML 解析器和 XSLT 处理器 (JAXP)
- 集成安全和加密扩展(JCE、JSSE、JAAS)
- Java网络启动
J2SE 5.0 (september 30, 2004) tiger [originally numbered 1.5]
J2SE 5.0(2004 年 9 月 30 日)虎 [原编号 1.5]
- Generics: provides compile-time (static) type safety for collections and eliminates the need for most typecasts (type conversion).
- Metadata: also called annotations; allows language constructs such as classes and methods to be tagged with additional data, which can then be processed by metadata-aware utilities.
- Autoboxing/unboxing: automatic conversions between primitive types (such as int) and primitive wrapper classes (such as integer).
- Enumerations: the enum keyword creates a typesafe, ordered list of values (such as day.monday, day.tuesday, etc.). Previously this could only be achieved by non-typesafe constant integers or manually constructed classes (typesafe enum pattern).
- Swing: new skinnable look and feel, called synth.
- Var args: the last parameter of a method can now be declared using a type name followed by three dots (e.g. Void drawtext(string... Lines)). In the calling code any number of parameters of that type can be used and they are then placed in an array to be passed to the method, or alternatively the calling code can pass an array of that type.
- Enhanced for each loop: the for loop syntax is extended with special syntax for iterating over each member of either an array or any iterable, such as the standard collection classesfix the previously broken semantics of the java memory model, which defines how threads interact through memory.
- Automatic stub generation for rmi objects.
- Static imports concurrency utilities in package java.util.concurrent.
- Scanner class for parsing data from various input streams and buffers.
- Assertions
- StringBuilder class (in java.lang package)
- Annotations
- 泛型:为集合提供编译时(静态)类型安全,并消除对大多数类型转换(类型转换)的需要。
- 元数据:也叫注解;允许使用附加数据标记诸如类和方法之类的语言结构,然后可以由元数据感知实用程序处理这些数据。
- 自动装箱/拆箱:原始类型(如 int)和原始包装类(如整数)之间的自动转换。
- 枚举: enum 关键字创建一个类型安全的、有序的值列表(例如 day.monday、day.tuesday 等)。以前这只能通过非类型安全的常量整数或手动构造的类(类型安全枚举模式)来实现。
- Swing:新的可换肤外观和感觉,称为 synth。
- Var args:现在可以使用后跟三个点的类型名称来声明方法的最后一个参数(例如 Void drawtext(string... Lines))。在调用代码中,可以使用任意数量的该类型的参数,然后将它们放在要传递给该方法的数组中,或者调用代码可以传递该类型的数组。
- 为每个循环增强:for 循环语法使用特殊语法进行了扩展,用于迭代数组或任何可迭代对象的每个成员,例如标准集合类修复了 Java 内存模型以前破坏的语义,它定义了线程如何通过内存进行交互.
- rmi 对象的自动存根生成。
- 静态在包 java.util.concurrent 中导入并发实用程序。
- 用于解析来自各种输入流和缓冲区的数据的扫描器类。
- 断言
- StringBuilder 类(在 java.lang 包中)
- 注释
Java SE 6 (december 11, 2006) mustang sun replaced the name "J2SE" with java se and dropped the ".0" from the version number. Beta versions were released in february and june 2006, leading up to a final release that occurred on december 11, 2006. The current revision is update 20.
Java SE 6(2006 年 12 月 11 日)mustang sun 将名称“J2SE”替换为 java se 并从版本号中删除了“.0”。Beta 版本于 2006 年 2 月和 6 月发布,最终版本于 2006 年 12 月 11 日发布。当前修订版是更新 20。
- Support for older win9x versions dropped.
- Scripting lang support: Generic API for integration with scripting languages, & built-in mozilla javascript rhino integration
- Dramatic performance improvements for the core platform, and swing.
- Improved web service support through JAX-WS JDBC 4.0 support
- Java compiler API: an API allowing a java program to select and invoke a java compiler programmatically.
- Upgrade of JAXB to version 2.0: including integration of a stax parser.
- Support for pluggable annotations
- Many GUI improvements, such as integration of swingworker in the API, table sorting and filtering, and true swing double-buffering (eliminating the gray-area effect).
- 不再支持旧的 win9x 版本。
- 脚本语言支持:用于与脚本语言集成的通用 API,以及内置的 mozilla javascript rhino 集成
- 核心平台和摆动的显着性能改进。
- 通过 JAX-WS JDBC 4.0 支持改进了 Web 服务支持
- Java 编译器 API:允许 Java 程序以编程方式选择和调用 Java 编译器的 API。
- 将 JAXB 升级到 2.0 版:包括集成 stax 解析器。
- 支持可插入注解
- 许多GUI改进,例如在API中集成swingworker,表格排序和过滤,以及真正的swing双缓冲(消除灰色区域效应)。
Java se 6 update 10 A major enhancement in terms of end-user usability.
Java se 6 update 10 终端用户可用性方面的重大改进。
- Java Deployment Toolkit, a set of javascript functions to ease the deployment of applets and java web start applications.
- Java Kernel, a small installer including only the most commonly used jre classes. Enhanced updater.
- Enhanced versioning and pack200 support: server-side support is no longer required.
- Java quick starter, to improve cold start-up time.
- Improved performance of java2D graphics primitives on windows, using direct3D and hardware acceleration.
- A new Swing look and feel called NIMBUS and based on synth.
- Next-generation java plug-in: applets now run in a separate process and support many features of web start applications.
- Java 部署工具包,一组 javascript 函数,用于简化小程序和 java web start 应用程序的部署。
- Java Kernel,一个小型安装程序,仅包含最常用的 jre 类。增强的更新程序。
- 增强的版本控制和 pack200 支持:不再需要服务器端支持。
- Java 快速启动器,改善冷启动时间。
- 使用 direct3D 和硬件加速改进了 windows 上 java2D 图形基元的性能。
- 一种名为 NIMBUS 并基于合成器的新 Swing 外观和感觉。
- 下一代java插件:小程序现在运行在一个单独的进程中,支持web启动应用程序的许多功能。
Java se 6 update 12 This release includes the highly anticipated 64-bit java plug-in (for 64-bit browsers only), windows server 2008 support, and performance improvements of java and JAVAFX applications.
Java se 6 update 12 此版本包括备受期待的 64 位 java 插件(仅适用于 64 位浏览器)、windows server 2008 支持以及 java 和 JAVAFX 应用程序的性能改进。
...........
…………
You can check in wikipediatill latest update.
您可以查看维基百科直到最新更新。
回答by stacker
回答by Stephen C
I have created the project using the JDK 1.4. Now I want to use JDK 1.6 version in my project. For this what steps are required.
我已经使用 JDK 1.4 创建了该项目。现在我想在我的项目中使用 JDK 1.6 版本。为此需要哪些步骤。
Actually, there is (almost) nothing that you need to start to make a JDK 1.4 application run using JDK 1.6. In nearly all cases, you simply need to recompile the code with the JDK 1.6 compiler and run it in a JDK 1.6 JVM. The only problems you are likely to encounter are:
实际上,使用 JDK 1.6 运行 JDK 1.4 应用程序时(几乎)不需要任何操作。在几乎所有情况下,您只需要使用 JDK 1.6 编译器重新编译代码并在 JDK 1.6 JVM 中运行它。您可能遇到的唯一问题是:
If your code uses "enum" as an identifier, you will need to change it to something else.
enum
is a keyword starting in Java 1.5.If your code directly depends on Sun proprietary / internal classes, you may need to deal with unannounced API changes.
You might find the certain official API classes or methods have been marked as deprecated.
There are a small number of changes in API implementations / behaviors with each release that may impact your application. These are typically highlighted in the document on upgrading.
如果您的代码使用“enum”作为标识符,则需要将其更改为其他内容。
enum
是从 Java 1.5 开始的关键字。如果您的代码直接依赖于 Sun 专有/内部类,您可能需要处理未宣布的 API 更改。
您可能会发现某些官方 API 类或方法已被标记为已弃用。
每个版本的 API 实现/行为都有少量更改,可能会影响您的应用程序。这些通常在升级文档中突出显示。
Once you have got your application working on Java 1.6, you can then think about whether and when to start using the Java 1.5 language extensions, and the new / enhanced APIs in the class libraries.
一旦您的应用程序在 Java 1.6 上运行,您就可以考虑是否以及何时开始使用 Java 1.5 语言扩展以及类库中的新/增强 API。
Means I want to know the what changes is require in code to get a JDK 1.6 feature.
意味着我想知道代码中需要进行哪些更改才能获得 JDK 1.6 功能。
Almost no changes are required. But obviously, if you want or need to use a new feature you will need to change your code to do that.
几乎没有变化需要。但很明显,如果您想要或需要使用新功能,则需要更改代码才能做到这一点。
Wikipedia has an summaryof the most significant changes made across various Java releases.
维基百科总结了在各种 Java 版本中所做的最重要的更改。
UPDATE
更新
As of May 2014, Java 6 has been "end-of-lifed", and Java 8 has been released for a month or so (with no significant early release number dramas). You should now be thinking about moving to at least Java 7, and probably Java 8.
到 2014 年 5 月,Java 6 已经“寿终正寝”,Java 8 已经发布了一个月左右(没有明显的早期发布号剧)。您现在应该考虑至少迁移到 Java 7,并且可能迁移到 Java 8。
The same principles apply. Recompile and run your regression tests, and you will most likely to be good to go. Then start learning all about the Java 8 language extensions.
同样的原则也适用。重新编译并运行回归测试,您很可能会顺利进行。然后开始学习有关 Java 8 语言扩展的所有信息。
回答by Fakrudeen
There is a big difference in behaviour for volatile keyword in 1.5 - more along the lines of C# away from C++ behaviour. But it only makes the code safer. So no code changes.
1.5 中 volatile 关键字的行为有很大的不同——更多的是沿着 C# 的路线远离 C++ 的行为。但这只会使代码更安全。所以没有代码更改。