how to jar the resulting .class files after compilation
Durand Grimmett
Greenhorn
Joined: Jun 02, 2004
Posts: 16
posted
0
Hello all, Right now the code that I have posted below will compile the two .java files provided....and it will also jar these files...But I want to jar the resulting .class files that get generated after the compilation....
However, the compile method doesn't return any files, it returns a boolean that indicates whether the compile was successful or unsuccessful. After a successful compilation The .class files are placed inside my working directory. As the code works now, it jars the .java files because those are the files that i past it. Can anyone help me to figure out how to jar the .class files that result from the compile?
//This method allows the user to name the jar file and choose the files to jar
public void compileAndJar() { System.out.println("Entering the compileANdJar() Method....");
// These are the files to include in the Jar file String[] filenames = new String[]{interfaceFile.getName(), handlerFile.getName()}; System.out.println("INTERFACE FILE NAME----> "+interfaceFile.getName()+" HANDLER FILE NAME----> "+handlerFile.getName());
//compile the interface and handler files try { sun.tools.javac.Main comp = new sun.tools.javac.Main(System.out, null); boolean iFacesuccess = comp.compile(filenames); System.out.println(comp.compilationPerformedSuccessfully()); } catch(Exception e) { e.printStackTrace(); }
// Create a buffer for reading the files byte[] buf = new byte[1024];
try { // Create the jar file String outFilename = jarTextField1.getText(); //Allow the user to set this variable System.out.println("JAR FILE NAME----> "+outFilename);