Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Beginning Java and the fly likes Problem with package statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

Problem with package statement

raghu yeggina

Joined: Feb 11, 2009
Posts: 27
hi friends,

here is a small java program

package com.raghu.scjp.chapter1;
public class JavaBeans{
public static void main(String args[]){
SubJavaBeans jb=new SubJavaBeans();
class SubJavaBeans{
private int size;
private boolean status=true;
public int getSize(){
return size;
public void setSize(int size){
public boolean isStatus(){
return status;
public void setStatus(boolean status){

i have set the classpath and path and java_home variables through the environmental variables in my system.

i am compiling it at commandprompt from d:\raghu folder and the class file is getting placed in the respective d:\raghu\com\raghu\scjp\chapter1 folder

but the problem is that i am getting an error while running the program using 'java' from the commandprompt i'm getting the 'noclassfoundererror' when i try to run from both d:\raghu and d:\raghu\com\raghu\scjp\chapter1

the entire issue is not there when i comment the first line and compile and run it at the same place..

can anyone please help me sort out the problem and suggest how to run this program successfully using the package statement
Ankit Garg

Joined: Aug 03, 2008
Posts: 9465

Raghu please don't double post the same thing in different forums...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
It is sorta covered in the JavaRanch Style Guide.
subject: Problem with package statement
It's not a secret anymore!