在Eclipse中的JUnit测试中发生错误206 [英] Error 206 occures on JUnit test in Eclipse

查看:140
本文介绍了在Eclipse中的JUnit测试中发生错误206的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在Eclipse中运行JUnit测试类时遇到问题。

I have a problem when i try to run JUnit test class in Eclipse.


执行命令行时发生异常。
无法运行程序C:\Program Files\Java\jre7\bin\javaw.exe(在目录C:\Users\User\Documents\Projects \ MyProject中):CreateProcess error = 206,文件名或扩展名太长

Exception occurred executing command line. Cannot run program "C:\Program Files\Java\jre7\bin\javaw.exe" (in directory "C:\Users\User\Documents\Projects\MyProject"): CreateProcess error=206, The filename or extension is too long

收到此错误后,我开始搜索如何修复问题...但是现在我生成了包含我需要的所有jar的MANIFEST文件,但我不知道如何将新的清单文件传递给项目以及如何处理我的lib目录中的jar?

After I received this error I started to search how to fix the problem... However now I generated MANIFEST file that contains all of the jars that i need, but I don't know how to pass the new manifest file to the project and also what to do with the jars in my lib dir?

提前致谢!

编辑:

我有SimpleTest类和TestRunner类

I have SimpleTest class and TestRunner class

public class SimpleTest {

     @Test
       public void testAssertions() {

          String str1 = new String ("abc");
          String str2 = new String ("abc");

          assertEquals(str1, str2);       
     }
    }

package com.epb.junit;

import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;

public class TestRunner {
   public static void main(String[] args) {
      Result result = JUnitCore.runClasses(SimpleTest.class);
      for (Failure failure : result.getFailures()) {
         System.out.println(failure.toString());
      }
      System.out.println(result.wasSuccessful());
   }
} 

这里没什么有趣的,我只需要知道如何打包我正在使用的所有JAR文件,因为它们太多了......我制作了一个包含所有这些文件的清单文件,但我不知道如何传递它而不是JAR文件。

Nothing interesting here, I just need to know how to pack all of my JAR files which I am using, because they are too many... I made a manifest file with all of them but I don't know how to pass it instead of JAR files.

PS我正在使用Eclipse运行测试类 - >运行方式 - > JUnit测试选项。发生错误后,我已经制作了这个TestRunner类,我将它作为Java应用程序运行但仍然是错误206.
从我读到的东西中我意识到我的构建路径太长了,因为有很多JARS所以现在我正在寻找一种方法来缩短这个路径并将罐装入一个。我试图将lib文件夹导出到Jar文件中,但它不起作用。

P.S I am running the test class with Eclipse -> Run As -> JUnit Test option. After the error occured I've made this TestRunner class and I am running it as Java Application but still Error 206. From the things that I read I realized that my Build Path is too long, because there are a lot of JARS so now I'm looking to find a way to shorten this Path and to pack the jars into one. I've tried to export the lib folder into Jar file but it doesn't worked.

编辑2

我之前尝试的最后一件事是创建一个路径jar,其中只包含Manifest.mf文件。我把这个jar放在我的项目Build Path而不是所有其他Jars中但仍然没有结果......现在项目的内置路径有错误...

The last thing that I tried just before a moment is to create a "pathing jar" which contains only Manifest.mf file inside it. I put this jar in my project Build Path instead of all other Jars but still no result... now the project has errors for the Built Path...

推荐答案

您需要做的就是按照以下步骤操作:

All you need to do is to follow these steps:


  1. 复制你的eclipse / plugins / org.eclipse .jdt.launching_3.4。*。jar到plugins文件夹之外的一个安全的
    位置,这样你总能找到一种方法。

  2. 关闭Eclipse。

  3. 将* .jar重命名为* .zip

  4. 打开zip文件并将附件中的4个类文件复制到
    org\eclipse\jdt\internal\launching(替换现有文件)

  5. 转到zip文件中的META-INF并删除除MANIFEST.MF之外的所有文件

  6. 将MANIFEST.MF解压缩到您的磁盘并使用文本编辑器进行编辑。

  7. 从第一个NAME:条目开始删除所有内容。

  8. 确保在fi的末尾留下两个(2)换行符le!

  9. 保存MANIFEST.MF并将其复制回zip文件。

  10. 将* .zip重命名为* .jar

  11. 用Eclipse / plugin目录中的jar替换修改后的jar!

  12. 享受!

  1. Copy your eclipse/plugins/org.eclipse.jdt.launching_3.4.*.jar to a safe place outside of the plugins folder, so that you always have a way to revert.
  2. Close Eclipse.
  3. Rename the *.jar to *.zip
  4. Open the zip file and copy the 4 class files from the attachment to org\eclipse\jdt\internal\launching (replace existing files)
  5. Go to META-INF in the zip file and delete all files except MANIFEST.MF
  6. Extract MANIFEST.MF to your disk and edit it with a text editor.
  7. Remove everything starting from the first "NAME:" entry.
  8. Make sure you leave two (2) line break characters at the end of the file!
  9. Save the MANIFEST.MF and copy it back into the zip file.
  10. Rename the *.zip back to *.jar
  11. Replace the modified jar with the jar in you Eclipse/plugin directory!
  12. Enjoy!

PS。第4步的 ATTACHMENT 可以从这里下载:

PS. ATTACHMENT from step 4 can be downloaded from here:


https://bugs.eclipse.org/bugs/attachment.cgi?id=216637

感谢Mr.Markus Keller创造了这些步骤!

Thanks to Mr.Markus Keller who created those steps!

这篇关于在Eclipse中的JUnit测试中发生错误206的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆