Programmatically compile Java class in a package stored in an arbitrary sub folder -
I am looking to compile an application in Java, which is composed of several Java classes in certain packages. On the command line, I can change the folder with the root package and type:
javac rootpackage / subpackage / *. Java
or
javac rootpackage / * / * to compile all Java classes in all the primary subpages of your rootpackage. Java
However I want to be able to do this within the Java application. (The idea is that we provide an application to the students in which the unit tests are conducted. Unit tests need to be run against their code, the application creates a JR file containing their source files which are used for testing The result is 'Watermark'. It works fine, but we want to make sure that the tested class files have been submitted to the sources Built files, because the program idea to compile the Java sources).
The problem is that each student store in their arbitrary condition, their root package, and I can not pass the location of the file on the Java compiler (javax.tools).
Is it possible, and if so, then any indication can be given about how
more information:
A student has a folder structure:
/ P>
/ home / student / work / java / myproject /
containing the root package They launch the application (probably stored in this folder - and there is no problem in this way - though much more than being stored) that asks for the folder that contains the root packs Included. After entering, students have clicked the Create a JR button, which compiles files in their packages, runs tests on new compiled files and then creates a jar
Think about this problem It is possible that students ask to install the 'Create JR Build' application in the folder containing their root package.
You can see at the top of each .java file for the beginning:
< P> package com.blah Blah.assignment; Look for the name of the package name and then look for the first directory in the beginning of your search path (in this example), and then give the Javacompler object to this path, or I have misunderstood your question? Just consider the Javax.tools package, do not create the overall wrapper for Java Filenamerer, which wraps the forwarding JavaFile Manager, for the appropriate initial directory in the student's source directory such as GetFileForInput or getJavaFileForInput Forward all requests.
Comments
Post a Comment