Forums Register Login

Bean is not compiling...............

+Pie Number of slices to send: Send
Hi,
I have one problem.

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
+Pie Number of slices to send: Send
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".
+Pie Number of slices to send: Send
If you look closely at this tiny ad, you will see five bicycles and a naked woman:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 808 times.
Similar Threads
unable to compile servletListener
please help me to resolve this problem
Package Problem
compiling package program error
how to compile
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 00:50:15.