Why if I try to execute a class containing the main() method from within its package I obtain an error message?
I have a Main class containing the main() method declared into a package named mainPkg . Now I use an ANT script to perform the compilation with Javac, this tartget: <target name="compile" depends="clean"> <mkdir dir="build/classes"/> <echo>INTO compile TASK</echo> <echo>BASE DIR: ${basedir}</echo> <echo>CLASSPATH: ${basedir}\lib\ojdbc6.jar</echo> <javac srcdir="src/mainPkg/" destdir="build/classes"> <classpath> <fileset refid="classpath.compile"/> </classpath> </javac> </target> Ok it works and it create the compiled Main.class file inside this directory (situated in the project root): build