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 8 of 8

Thread: javac help

  1. #1
    Member
    Join Date
    Jun 2010
    Posts
    75
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default javac help

    How do I get the javac compiler to compile a file in any directory from any directory?

    I want to be able to compile a source file when I'm in neither the root directory for the source file nor the root directory for the compiler.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,552
    Thanks
    45
    Thanked 1,953 Times in 1,927 Posts

    Default Re: javac help

    in any directory from any directory
    Have you tried specifying the full paths

  3. #3
    Member
    Join Date
    Jun 2010
    Posts
    75
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: javac help

    Quote Originally Posted by Norm View Post
    Have you tried specifying the full paths
    That works to a certain extent (i.e., if the path names don't have spaces in them).

    Is there away to get them to work in all instances?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,552
    Thanks
    45
    Thanked 1,953 Times in 1,927 Posts

    Default Re: javac help

    Depends on the OS. Not really a java programming problem.

  5. #5
    Member
    Join Date
    Jun 2010
    Posts
    75
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: javac help

    Where would have been a more appropriate place to ask?

  6. #6
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,097
    Thanks
    169
    Thanked 779 Times in 725 Posts
    Blog Entries
    5

    Default Re: javac help

    You need to set the path/classpath on your system, which is system dependent. I'd say do a web search for these keywords for instructions for you system. In windows, it has to do with going to your control panel->System->Advanced->Environmental Variables (I can't reproduce the instructions which again, you can find by doing a web search). Setting things up properly will allow you to call javac from any directory, which I believe is what you are asking.

  7. #7
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    489
    Thanks
    8
    Thanked 45 Times in 43 Posts

    Default Re: javac help

    Quote Originally Posted by mjpam View Post
    That works to a certain extent (i.e., if the path names don't have spaces in them).

    Is there away to get them to work in all instances?
    Enclose the path in double quotes.

    db

  8. #8
    Member
    Join Date
    Feb 2011
    Location
    Pittsburgh
    Posts
    62
    My Mood
    Angelic
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Lightbulb Re: javac help

    OK this is very simple.... I AM USING WINDOWS VISTA

    COPYING THE FILE LOCATION/ADDRESS OF javac
    All you do is go to the bin file where javac program is kept.
    Right click on the file to open the pop-up menu.
    Choose properties.
    Copy (Highlight, then Ctrl + C) the "Location" information, not the word "Location".

    PASTING javac FILE ADDRESS AT THE END OF THE CURRENT PATH INFORMATION
    Go to 'System, Advanced System Settings, Environment Variables.
    In the "System Variables" part of the "Advanced" tab, select "Path" or "PATH" if it is capitalized.
    Press "Edit".
    In the "Edit System Variable" screen, in the "Variable Value:" text box, scroll to the end of the info already there, DO NOT DELETE ANYTHING, at the end, leave no space, but enter a ";" then press Ctrl + V to paste the info into the space next to the ";" you just entered, save and close.

    FINAL STEP
    You will have to reopen your "Run.." window because the change will not work until you do.

    Now you can type in javac WhyIsThisSoDifficult.java, without having to add the file location of the javac first.

    More info on the subject

Similar Threads

  1. [SOLVED] can't run javac directly from command prompt
    By epezhman in forum Java IDEs
    Replies: 7
    Last Post: January 12th, 2011, 06:38 PM
  2. Problem of executing java.exe. How to code from absolute scratch?
    By sepalm in forum Java Theory & Questions
    Replies: 13
    Last Post: November 12th, 2008, 06:48 AM