I am accessing JavaBeans by using jsp.It working but i want to test my bean first and in doing so i am getting an error message. I have BakedBean.java(JavaBean)file as ---------------------------------------------- package testpackage;
public class BakedBean { private String level = "half-baked"; private String goesWith = "hot dogs";
public String getLevel() { return(level); }
public void setLevel(String newLevel) { level = newLevel; }
public String getGoesWith() { return(goesWith); }
public void setGoesWith(String dish) { goesWith = dish; } } --------------------------------------------- It is compling very well.Now i have BakedBeanTest.java file which will test above bean but when i am compiling this file i am getting an error message.I have both the files in same package code for this file is as: ----------------------------------------------- package testpackage;
public class BakedBeanTest { public static void main(String[] args) { BakedBean bean = new BakedBean(); System.out.println("Original bean: " + "level=" + bean.getLevel() + ", goesWith=" + bean.getGoesWith()); if (args.length>1) { bean.setLevel(args[0]); bean.setGoesWith(args[1]); System.out.println("Updated bean: " + "level=" + bean.getLevel() + ", goesWith=" + bean.getGoesWith()); } } }
-------------------------------------------------------------- Will anybody please tell me what is the problem the error which i am getting is as ------------------------------------------------------------ E:\testpackage>javac BakedBeanTest.java BakedBeanTest.java:7: cannot find symbol symbol : class BakedBean location: class testpackage.BakedBeanTest BakedBean bean = new BakedBean(); ^ BakedBeanTest.java:7: cannot find symbol symbol : class BakedBean location: class testpackage.BakedBeanTest BakedBean bean = new BakedBean(); ^ 2 errors ------------------------------------------------------------ Please tell me solution for this
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35252
7
posted
0
It will work if you change the directory to be one level higher, i.e. directly in the E:\ directory. If you then use "javac testpackage\BakedBeanTest.java" the other class will be found (because the directory hierarchy hatches the package hierarchy).
Alternatively, you can compile both classes in one go: "javac *.java".