使用php或java解析java?

I am building a web application which in the back end needs to parse a java file and save certain values in a database. This has to be triggered by the user and set on a schedule.

What is the best way of doing this? Should I do this using php or java? Know how to parse the file in both languages however java has reflection which would make it easier and reduce the likelihood of error however I have no idea now to call a java file from the front end e.g. onclick of a button.

The front end technologies I'm looking to use are html, css, javascript and ajax. I'm not looking to use struts e.t.c as I am not familiar with them and I am limited on time.

Thanks

Reflection will not help in this case, because you need to parse the code (Java in this case) and interpret as you which. Therefore you will need to build an AST of your file.

AST (Abstract Syntax Tree) could be build in Java using Eclipse JDT. On maven central:

    <dependency>
        <groupId>org.eclipse.jdt</groupId>
        <artifactId>org.eclipse.jdt.core</artifactId>
        <version>3.12.2</version>
    </dependency>

Eclipse JDT is a document model that could be compared to a DOM Tree, with the DOM Tree you can access elements, attributes and so on of an XML. The AST has the same scope, you can access for example the class Name, or methods of that class extracting parameters names and types for each method without instantiate an Object based on that class. Other artefacts like documentation or comments are accessible over JDT.

Reflection can be applied just in case that you have the class loaded on to some class loader, and even so, there are some information like documentation or parameters names that you cannot access through reflection.

A good start is read this hands post: http://www.vogella.com/articles/EclipseJDT/article.html#jdt

And a simple start could be done using the code I posted on this answer