1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

executing the program in subpackage

Discussion in 'Java' started by Kailash, Sep 18, 2007.

  1. Kailash

    Kailash New Member

    Joined:
    Jul 24, 2007
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    I have created a java program and prevented the class file to be saved in package where source file is saved say pracjava by using these steps:

    include the package abc like that
    package abc; in program

    and then compling the prog in this way
    e:\pracjava\javac -d . prog.java

    this creating class file inside abc package which is inside pracjava package

    but when i am executing program using
    e:\pracjava\java prog
    then it is not running
    giving error no classdef found error

    i have set path to c:\jdk1.5\bin
    and classpath to e:\pracjava


    however when compling the program using
    e:\pracjava\javac prog.java

    and then executing it. It is not giving any error
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    The filename has to be the same as the class/package name, like if your classname is ABC, the filename has to be ABC.java!
     
  3. Kailash

    Kailash New Member

    Joined:
    Jul 24, 2007
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    name of class file is prog not abc. abc name of subpackage that created by command

    javac -d . prog.java
     

Share This Page