Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-core-dev] How to open existing java package (source code) programatically?

Hi Tharaka,

I suppose this is the kind of question that should rather be asked
in the news group (eclipse.tools.jdt), quoting Daniel Megert from 
a recent post:
  "Please use the newsgroup for such questions. This list is reserved for the
  developers of JDT Core itself."

That said, from a brief look at your code you seem to be happily mixing
paths in the file system and paths in the workspace. If cmdArgs[0] is
the absolute filesystem path to the project, these lines look bogus:

  Path dir = new Path(cmdArgs[0]);
  ..
  IClasspathEntry cp = JavaCore.newSourceEntry(dir);

newSourceEntry expects a "workspace-relative path". Similarly this line:

  IPackageFragmentRoot srcRoot = javaProj.getPackageFragmentRoot(cmdArgs[0]);

should probably better use a relative path, too. 
Anyway, that's what the workspace is for in the first place: 
abstracting from the physical file system!

But these are just a few quick guesses.

Stephan



Back to the top