Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Problem with file creation

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with file creation

    I have java aplication that in some point it uses javac to compile some java files Then I use reflection and .class dont exist is there a way to make the process wait until files are created in my hard disk


    Sorry about my pure English


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Problem with file creation

    Can you post the code that shows how you are calling javac?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem with file creation

    here is the code
    public static void compileFiles(String path)
    {
    System.out.println("Class Creation Started");
    try
    {
    Process rt =Runtime.getRuntime().exec("cmd /c start /min javac "+ path +"\\*.java");

    rt.waitFor();
    System.out.println("exitvalue:" +rt.exitValue());
    }
    catch (Exception e) {System.out.println("Unexpected exception Trying to Execute Job: " +e);}

    System.out.println("Class Creation Ended");
    }

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Problem with file creation

    Have you tried executing javac directly instead of using cmd?

    Also there is a class that will do a compile via method calls.
    See the API doc for the JavaCompiler interface.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Mar 2011
    Posts
    32
    My Mood
    Worried
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem with file creation

    Dear Hliasprev is this code is right ???



    Quote Originally Posted by hliasprev View Post
    here is the code
    public static void compileFiles(String path)
    {
    System.out.println("Class Creation Started");
    try
    {
    Process rt =Runtime.getRuntime().exec("cmd /c start /min javac "+ path +"\\*.java");

    rt.waitFor();
    System.out.println("exitvalue:" +rt.exitValue());
    }
    catch (Exception e) {System.out.println("Unexpected exception Trying to Execute Job: " +e);}

    System.out.println("Class Creation Ended");
    }

  6. #6
    Junior Member
    Join Date
    May 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem with file creation

    you need to specify the full path, not just the directory and the file name to create a file or even check it's existence. I am sure they helps you.

Similar Threads

  1. Replies: 6
    Last Post: October 26th, 2012, 10:52 AM
  2. need help in program creation
    By vinaysa86 in forum Loops & Control Statements
    Replies: 4
    Last Post: August 15th, 2012, 07:11 PM
  3. Apache XML-RPC server creation problem
    By r0x in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 10th, 2011, 09:52 AM
  4. [SOLVED] minesweeper game creation problem
    By kaylors in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 27th, 2009, 04:06 PM
  5. WAR file creation in Eclipse JEE
    By katty in forum Java IDEs
    Replies: 5
    Last Post: May 21st, 2009, 09:45 AM