0

I can add a JRE in classpath programatically using

entries.add(JavaRuntime.getDefaultJREContainerEntry());

where entries is a classpathyentry. Anyone know how to do this for JUnit?

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
jantox
  • 2,185
  • 4
  • 21
  • 22
  • Check this SO question on [loading-jars-dynamically-at-runtime](http://stackoverflow.com/questions/60764/how-should-i-load-jars-dynamically-at-runtime) – asgs Jul 11 '12 at 05:33

2 Answers2

1

Found this one

IClasspathEntry junit4Entry = BuildPathSupport.getJUnit4ClasspathEntry();
Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
jantox
  • 2,185
  • 4
  • 21
  • 22
1

If I try

IClasspathEntry junit4Entry = BuildPathSupport.getJUnit4ClasspathEntry();

I get

Discouraged access: The type 'ClasspathEntry' is not API (restriction on required library /{path}/org.eclipse.jdt.core_3.10.0.v20140604-1726.jar')

So

IClasspathEntry junit4Entry = JavaCore.newContainerEntry(JUnitCore.JUNIT4_CONTAINER_PATH);

works better, no warnings ;)

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
SWYM
  • 43
  • 1
  • 8