简体   繁体   English

从JDK 1.5到1.6的代码迁移

[英]Code Migration from JDK 1.5 to 1.6

What are the steps to be followed for Migration of code from JDK 1.5 to 1.6. 将代码从JDK 1.5迁移到1.6时要遵循的步骤是什么?

Steps followed : 遵循的步骤:

  1. Changed the build Patch of Project as JDK1.6 将项目的构建修补程序更改为JDK1.6
  2. Changed the Compiler as 6 将编译器更改为6
  3. Clean and deploy the Project 清理并部署项目
  4. I was getting Compilation error as 我收到编译错误
*** ERROR ***: Thu Apr 01 05:17:06 PDT 2010    org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DeploymentDescriptorLoadException: WEB-INF/web.xml
    Stack trace of nested exception:
    java.lang.ClassCastException: org.eclipse.jst.javaee.web.internal.impl.WebAppDeploymentDescriptorImpl cannot be cast to org.eclipse.jst.j2ee.webapplication.WebApp
        at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.War22ImportStrategyImpl.loadDeploymentDescriptor(War22ImportStrategyImpl.java:87)
        at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.War22ImportStrategyImpl.importMetaData(War22ImportStrategyImpl.java:81)
        at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.WARFileImpl.getDeploymentDescriptor(WARFileImpl.java:145)  



*** ERROR ***: Thu Apr 01 05:17:06 PDT 2010    org.eclipse.wst.validation.internal.core.ValidationException: CHKJ3000E: WAR Validation Failed: org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DeploymentDescriptorLoadException: WEB-INF/web.xml
        at org.eclipse.jst.j2ee.model.internal.validation.WarValidator.validateInJob(WarValidator.java:343)
        at org.eclipse.jst.j2ee.internal.web.validation.UIWarValidator.validateInJob(UIWarValidator.java:111)
        at org.eclipse.wst.validation.internal.operations.ValidatorJob.run(ValidatorJob.java:75)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

In the vast majority of cases, you don't need to do anything at all. 在绝大多数情况下,您根本不需要做任何事情。 Even recompiling is not strictly necessary. 即使重新编译也不是绝对必要的。

The few incompatibilities that exist between Java 5.0 and 6.0 are documented in the JDK 6 Adoption Guide . JDK 6采用指南中记录了Java 5.0和6.0之间存在的一些不兼容性。

The code that ran on Java 1.5 will run on 1.6 without any modifications(in you weren't using any internal APIs that is). 在Java 1.5上运行的代码将在1.6上运行而不进行任何修改(在您没有使用任何内部API的情况下)。 The public Java api is always forward compatible. 公共Java API始终向前兼容。

使用新的JDK重新编译,检查警告(可能不推荐使用某些类或方法),检查应用程序是否按预期工作。

I did following and it works fine 我做了以下,它工作正常

Changed the build Patch of Project as JDK1.6
Changed the Compiler as 6 

Download and install JDK 6. Update any environmental variables like JAVA_HOME, JDK_HOME. 下载并安装JDK 6.更新任何环境变量,如JAVA_HOME,JDK_HOME。 Make sure that your IDE points to the new library (most IDEs will do it automatically if restarted after the environmental variables have been updated). 确保您的IDE指向新库(如果在更新环境变量后重新启动,大多数IDE将自动执行此操作)。 Update the project settings to use JDK 6 in your IDE for each project respectively. 更新项目设置以分别在IDE中为每个项目使用JDK 6。

That depends on your application I suppose here are the list of new features to 1.6 all your code however should work fine. 这取决于你的应用程序我想这里是1.6所有代码的新功能列表,但应该工作正常。

link java 1.6 features 链接java 1.6功能

I fixed a similar error by replacing: 我通过替换修复了类似的错误:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
     version="2.4">

with: 有:

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
     version="3.1">

When I did this replacement at web.xml, this CHKJ3000E has gone away. 当我在web.xml上做这个替换时,这个CHKJ3000E已经消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM