2

I want to make a java application that takes java source codes as input to create and visit their Abstract Syntax Trees, so I can make some statistics out of them.

I found this java parser: https://github.com/javaparser/javaparser

My questions are:

  • Is there a way to import that library into NetBeans? Maybe from a jar file?
  • Are there other parsers for what I want to do?
  • Is using NetBeans and java language the easiest way to do this or should I use a different IDE or different programming languages?

2 Answers 2

2

Some years ago I've done a prototype to analyze Java source. I used this library Recoder (manual) that do the dirty work for me (parsing and building a good designed AST).

It's a jar so you can use it with any kind of IDE.

Usually I use Eclispe as Java IDE. It has its own AST model and you can consider to use Eclipse JDT Eclipse JDT.

Sign up to request clarification or add additional context in comments.

Comments

0

I am not sure about NetBeans but you can create a project using maven or gradle and specify a dependency to JavaParser and you are done. It is that easy. Alternatively you may want to download the JavaParser jar from Maven central: it should not have any dependency so that would be enough.

Disclaimer: I am a contributor to JavaParser

2 Comments

I am quite new to github and the use of libraries, so can you explain me what maven is and how to use it?
Maven is a build system that you can use to declare dependencies. If you create a program and configure it for Maven you can say that your program uses libraries A, B and C. Maven will download A, B, C and verify if they have dependencies. If they do also their dependencies will be download etc. I cannot explain you how to use Maven in a comment but you can take a look here: maven.apache.org/guides/getting-started/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.