• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package problem

 
Syed Kamran Ali
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i have a problem i am trying to make a package abc where i want to put a test.java
i have createst test.java and placed it in abc folder.
But i dont know how to compile my class and then run the class.
I am using windowsXP and jdk1.4.
Please help.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Syed,
u shd try this steps,
1. make sure that u've statement "package abc" on top of the file test.java
2. make sure that u 've abc directory and test.java in there (as u already do have)
3. go to parent directory of the abc directory.
e.g. if u have following directory hierarchy,
c:\myprog\abc>
and test.java is there in this abc directory then,
u shd go to c:\myprog> and then do,
c:\myprog>javac abc/*.java
make sure that u 've "current directory" that is "." in the CLASSPATH. to set this u can do ,
c:\myprog>set CLASSPATH=%CLASSPATH%;. on the prompt and then should try javac as mentioned above.
now to run the code,
c:\myprog>java abc.test
that should do the job..
let me know if u face problems...
regards
maulin
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also,
i assumed u've the PATH variable set up properly and all...so u are able to execute "java", "javac" etc from any directory..
regards
maulin
 
Rajeshwari Natarajan
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is how ur class looks like,

from the same level as the abc folder, execute the following commands to compile and run the code.
 
Syed Kamran Ali
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have compiled the class by going into the directory abc
setting classpath to f:\abc
and using command javac test.java
a class is generated but the class doesn't run using command
java test witin abc directory. It gives a no commandDeFoundError
 
Syed Kamran Ali
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys its working now there was a problem with class path
Thanks Again
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic