How to compile packages in java?

前端 未结 4 1868
深忆病人
深忆病人 2020-12-01 01:55

I have written a simple package program:


  //A simple package

       package MyPack


       class Balance
       {
        String name;
        doubl         


        
4条回答
  •  忘掉有多难
    2020-12-01 02:02

    Try to create the folder named MyPack and move .class files in it or use following command line to compile the java code and it moves the .class files into MyPack folder.

    javac YourFileName.java -d .
    

    and run using,

    java MyPack.AccountBalance
    

    Have a look at javac tool

    From the tool doc : By default, the compiler puts each class file in the same directory as its source file. You can specify a separate destination directory with -d (see Options, below).

    and package tutorial.

提交回复
热议问题