What's up forum,
I've been extending my little project for some time now. So far what I'm trying to have this program create an empty .java file, then proceeding to compile and execute it. I'm aware it is still not complete. I haven't added the overwrite empty .java part of the code.
import java.io.*; public class Mercury { public static void main(String[] args) { Vector <String> ubicac = new Vector <String>(0, 1); Vector <String> nombre = new Vector <String>(0, 1); Vector <String> direct = new Vector <String>(0, 1); // SIMULADOR LOGIC ubicac.addElement("C:\\Users\\Andrew\\Desktop//"); nombre.addElement("Test.java"); direct.addElement(ubicac.elementAt(ubicac.size()-1)+nombre.elementAt(nombre.size()-1)); // CREATOR createFile(direct.elementAt(direct.size()-1)); public static void createFile(String S){ File file = new File(S); boolean blnCreated = false; try { blnCreated = file.createNewFile(); } catch(IOException ioe) { System.out.println("Error while creating a new empty file :" + ioe); } System.out.println("Was file " + file.getPath() + " created ? : " + blnCreated); } // COMPILER & EXECUTER - [!] REVISION NECESARIA: Recibir Param String que coincida con Vector PLACE.elementAt(i) (decidido por LOGIC) try { runProcess("javac " + nombre.elementAt(nombre.size()-1)); runProcess("java Test"); } catch (Exception e) { e.printStackTrace(); } public static void printLines(String name, InputStream ins) throws Exception { String line = null; BufferedReader in = new BufferedReader( new InputStreamReader(ins) ); while ((line = in.readLine()) != null) { System.out.println(name + " " + line); } } private static void runProcess(String command) throws Exception { // Process pro = Runtime.getRuntime().exec(command); printLines(command + " stdout:", pro.getInputStream()); printLines(command + " stderr:", pro.getErrorStream()); pro.waitFor(); System.out.println(command + " exitValue() " + pro.exitValue()); } } }
So far I'm trying to compile my code, and unfortunately its giving a basic problem apparently.
Shame on me really. I can't figure this one out.
I am creative just that I'm more of the empirical type learner.
I'm using Notepad++ w/cmd prompt.C:\Users\Andrew\Desktop>javac Mercury.java
Mercury.java:21: error: illegal start of expression
public static void createFile(String S){