How to compile a package by javac?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: How to compile a package by javac?

  1. #1
    Sean Guest

    How to compile a package by javac?


    Hi,

    Can anyone tell me how to compile java files in a package using javac? Thanks

    Sean

  2. #2
    mazin Guest

    Re: How to compile a package by javac?


    "Sean" <sliang@emptoris.com> wrote:
    >
    >Hi,
    >
    >Can anyone tell me how to compile java files in a package using javac? Thanks
    >
    >Sean


    you need to type this command line
    javac -d . Test.java
    that will gernreate the package for you
    example for that

    package com.sun.java.test
    public class Test {
    public static void manin(String args[] )
    {
    System.out.println( "hello world" );
    }

    when you complie this class by using javac -d . Test.java , that will gerrante
    this folder com/sun/java/test/Test.class

    to run this Class , you need to type this command line
    java com.sun.java.test.Test


    Regrads
    Mazin


  3. #3
    Paul Clapham Guest

    Re: How to compile a package by javac?

    Let's suppose that your package is named "sleeper". Then you should put
    your source files in a directory whose name is "sleeper", for a start. And
    remember that their first line must say "package sleeper;". Then to compile
    them using javac, change directory so your current directory is the
    **parent** of "sleeper".

    Then type "javac sleeper/AClass.java", inserting whatever compiler options
    you need, to compile your source. (Note that this doesn't quite work in
    Java 1.1.x under Windows, where you need to replace the / by \.)

    PC2

    Sean <sliang@emptoris.com> wrote in message news:3a846ca9$1@news.devx.com...
    >
    > Hi,
    >
    > Can anyone tell me how to compile java files in a package using javac?

    Thanks
    >
    > Sean




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center