Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error 206 occures on JUnit test in Eclipse

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

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

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?

Thanks in advance!

EDIT:

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());
   }
} 

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.

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.

EDIT 2

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...

like image 287
cyrat Avatar asked Oct 06 '22 03:10

cyrat


1 Answers

All you need to do is to follow these steps:

  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. ATTACHMENT from step 4 can be downloaded from here:

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

Thanks to Mr.Markus Keller who created those steps!

like image 149
cyrat Avatar answered Oct 13 '22 11:10

cyrat