Gordeev Pavel Gordeev Pavel - 27 days ago 6
Java Question

Can't execute packageclass

I want to execute this class from console by "java". I have no problems with compilation, but what do I have to write to call this class? If I don't specify the package, no problems.

package myfirstpackage;
// import myfirstpackage.*;
class MyFirstClass{
public static void main(String[] args) {
// MySecondClass msc = new MySecondClass();
// for( int i = 1 , j , size = Integer.parseInt( args[ 0 ] ) ; i <= size ; i++ ){
// for( j = 1 ; j <= size ; j++ ){
// msc.setFirst( i );
// msc.setSecond( j );
// System.out.printf( "%3d " , msc.multiplyFirtsAndSecond() );
// }
// System.out.println();
// }
System.out.println("A");
}
}

Answer Source

First compilation :

> javac classname.java

And then you can run it

> java classname

Hope it helps