Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Can I use JDT to parse Java project strictly using command-line?
Can I use JDT to parse Java project strictly using command-line? [message #1780930] Tue, 30 January 2018 07:29 Go to next message
Maruhan Park is currently offline Maruhan ParkFriend
Messages: 6
Registered: January 2018
Junior Member
Hello,

Typically, when you are parsing Java code with JDT, you make it as a plugin and do something like this where

1. You first make a project:
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(projectName);
project.create(null);
project.open(null);
IProjectDescription description = project.getDescription();
description.setNatureIds(new String[] { JavaCore.NATURE_ID });
project.setDescription(description, null);
IJavaProject javaProject = JavaCore.create(project); 


And then set the project to your ASTParser:

ASTParser parser = ASTParser.newParser(AST.JLS9);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setProject(javaProject);


Is there a way I can achieve what the above is doing without having to open Eclipse and run as a plugin? There has to be a way to create the same data structures programmatically by recreating the same environment to be as if it is running on the Eclipse IDE. Particularly, I feel like the easiest would be creating a "IJavaProject" object somehow.

What are some ways to do this?

I know making it a headless RCP application is a possibility, but I want to know if I can make it as a standalone Java application by using the appropriate jars or even modifying the jars and creating my own.

Re: Can I use JDT to parse Java project strictly using command-line? [message #1780933 is a reply to message #1780930] Tue, 30 January 2018 07:39 Go to previous messageGo to next message
Maruhan Park is currently offline Maruhan ParkFriend
Messages: 6
Registered: January 2018
Junior Member
Someone please help me delete the duplicate posts. It posted 3 in a row and I can't find a way to delete
Re: Can I use JDT to parse Java project strictly using command-line? [message #1780934 is a reply to message #1780930] Tue, 30 January 2018 07:39 Go to previous message
Maruhan Park is currently offline Maruhan ParkFriend
Messages: 6
Registered: January 2018
Junior Member
Someone please help me delete the duplicate posts. It posted 3 in a row and I can't find a way to delete
Previous Topic:Can I use JDT to parse Java project strictly using command-line?
Next Topic:What's the purpose of "bindingKeys" in the "createASTs" method for the "AST
Goto Forum:
  


Current Time: Fri Mar 29 08:31:09 GMT 2024

Powered by FUDForum. Page generated in 0.02627 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top