Results 1 to 6 of 6
  1. #1
    Tarasj is offline Member
    Join Date
    Mar 2012
    Posts
    14
    Rep Power
    0

    Default how to use -d to compile java code to separate class and java file

    yea i am having some problem in using the -d to compile the java code using the command prompt
    -please help me with the proper syntax and steps.
    Thanks

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default Re: how to use -d to compile java code to separate class and java file

    Quote Originally Posted by Tarasj View Post
    yea i am having some problem in using the -d to compile the java code using the command prompt
    -please help me with the proper syntax and steps.
    Thanks
    The -d flags come before anything else on the command line; they set system properties or change the behaviour of the JVM.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    gauravfzd's Avatar
    gauravfzd is offline Member
    Join Date
    Oct 2010
    Location
    India
    Posts
    72
    Rep Power
    0

    Default Re: how to use -d to compile java code to separate class and java file

    the syntax is :

    javac -d <target-path> -c <classpath> <source.java>

    -d option is most helpful if you are declaring packages in the Source code(*.java) files.

    -c is used to provide the external classes or library that will be needed by the compiler to compile the source code

  4. #4
    Tarasj is offline Member
    Join Date
    Mar 2012
    Posts
    14
    Rep Power
    0

    Default Re: how to use -d to compile java code to separate class and java file

    can you please provide a simple example

  5. #5
    gauravfzd's Avatar
    gauravfzd is offline Member
    Join Date
    Oct 2010
    Location
    India
    Posts
    72
    Rep Power
    0

    Default Re: how to use -d to compile java code to separate class and java file

    for eg:

    javac -d d:\classes\ -c d:\sources\ Test.java

  6. #6
    Tarasj is offline Member
    Join Date
    Mar 2012
    Posts
    14
    Rep Power
    0

    Default Re: how to use -d to compile java code to separate class and java file

    Thanks alot

Similar Threads

  1. Replies: 7
    Last Post: 08-29-2011, 06:35 PM
  2. Replies: 13
    Last Post: 06-29-2011, 07:25 AM
  3. how to separate this code in another class
    By Jhovarie in forum AWT / Swing
    Replies: 5
    Last Post: 03-01-2011, 05:08 PM
  4. Separate file for main and class
    By eel in forum New To Java
    Replies: 12
    Last Post: 09-18-2010, 08:24 AM
  5. Should I separate my code into separate files?
    By Inks in forum New To Java
    Replies: 0
    Last Post: 03-26-2009, 12:12 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •