• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Problem with package statement\

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
jb.setSize(10);
jb.isStatus();
System.out.println(jb.isStatus());
jb.setStatus(false);
jb.isStatus();
System.out.println(jb.getSize());
System.out.println(jb.isStatus());
}
}
class SubJavaBeans{
private int size;
private boolean status=true;
public int getSize(){
return size;
}
public void setSize(int size){
this.size=size;
}
public boolean isStatus(){
return status;
}
public void setStatus(boolean status){
this.status=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
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are you using this command

java JavaBeans

or this one

java com.raghu.scjp.chapter1.JavaBeans


Also raghu please Use Code Tags to make your program more readable...
 
raghu yeggina
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ankit,

i have been using

java JavaBeans

instead of packagename.classname syntax as you have specified. I have rectified it now.

Thanks a lot for the reply and also i am ignorant of the code tags before the earlier post and promise to use

them from now. Sorry for the inconvenience as i am new to Posting topics here.

Bye.
 
Ankit Garg
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

raghu yeggina wrote:Thanks a lot for the reply and also i am ignorant of the code tags before the earlier post and promise to use
them from now. Sorry for the inconvenience as i am new to Posting topics here.
Bye.



No problem buddy, No Need To Say Sorry
 
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic