Hi,all
I need a java parser for parsing any java file in any package,not only existing file ...Can i do this ? how?

Mar Na, you have 6 posts now that dance around but never really come out and tell what you are trying to accomplish.

In a few I see ready to use tools that have source so I would be left guessing what your big picture is here.

Do yourself a solid and reveal your big picture.

package javaapplication12;
public class  CyclomaticComplexity {
public static void main(String[]argv) throws ClassFormatException, IOException {

ClassParser parser=new ClassParser(CyclomaticComplexity.class.getResourceAsStream("/javaapplication12/CyclomaticComplexity.class"),"CyclomaticComplexity.class");
    JavaClass javaClass=parser.parse();
    }}}

Mr. rproffitt ,in this my code,java parser ,parsing only existing class in existing package,i want to modifiy class path and writing other class path from other package but isn't work!?

Ok, thank you very much to help me.

Look at the constructors for ClassParser. You are using the one that takes an input stream, which you get from you current class loader. It would be a lot easier to use the constructor that takes a file name, or if your class is in a jar, the one that takes a zip file and a file name.

How can i use it ? is there any example or website that clarify this?

It's a simple constructor. If you don't know how to use it then, to be honest, you are not yet ready to start using tools like this.

Ok , I know how to use it but , when I write path I get error ...

If you tell us what the error is then maybe we can help. Post the exact code and the complete error message.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.