Next: Importing a package, Previous: Moving a class into a package, Up: Packages in J.T.W. and Java [Contents][Index]
Suppose you want to move a class A from no package (the folder
~/jtw-tutorials) to a package called for argument’s sake
pkg.inner, the steps from Moving a class into a package
needs to be followed, the only difference being that the package spec
needs to be changed to and the file needs to be
moved into the folder package pkg.inner;pkg/inner. To run the class file you need
to invoke the following Make command:
make clean pkg/inner/A.run.
Here is the class definition for the file
~/jtw-tutorials/pkg/inner/A.jtw:
packagepkg.inner;publicclassAbeginpublicpropertyintdata;publicclassVarintdata2 = 666;publicconstructorA(intd)begindata = d;endpublicmethodvoidmeth1()beginSystem.out.println("meth1:" + data);endpublicmethodvoidmeth2()beginSystem.out.println("meth2:" + data);endpublicfunctionvoidfunc()beginSystem.out.println("func:" + data2);endbeginMainvarA a1 =newA(123); a1.meth1(); // prints out "meth1:123"varA a2 =newA(456); a2.meth2(); // prints out "meth2:456" A.func(); // prints out "func:666"endMainend