473,396 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

calling of function of one class using objects of another

first of all heres the code

// first file//
public class bottom
{
public static void main(String args[])
{
top obj=new top();
obj.display();
}
}


//second file//

public class top
{
public void display()

{
System.out.println("finaly i got the answer !");
}

}

both are saved in the same folder and i have double checked that the file name are same as that of class name.

now whenever i try to compile bottom i get the following error

bottom.java:7: cannot find symbol
symbol : class top
location: class bottom
top obj=new top();
^
bottom.java:7: cannot find symbol
symbol : class top
location: class bottom
top obj=new top();
^
2 errors

line numbers are not same, but anyways you would get it.

i dont know why it isn't able to detect top in the same folder.

please help
May 28 '08 #1
1 1100
BigDaddyLH
1,216 Expert 1GB
Classes are usually defined to be in packages. When you don't do this, the package defaults to the current directory. Then you need to set the classpath for javac.exe and java.exe:

Expand|Select|Wrap|Line Numbers
  1. javac -classpath . bottom.java
  2. java -classpath . bottom
Note the dot in those commands (dot = current directory)
May 28 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Michael Winter | last post by:
In an attempt to answer another question in this group, I've had to resort to calling the DOM method, Node.removeChild(), using a reference to it (long story...). That is, passing Node.removeChild....
19
by: Ross A. Finlayson | last post by:
Hi, I hope you can help me understand the varargs facility. Say I am programming in ISO C including stdarg.h and I declare a function as so: void log_printf(const char* logfilename, const...
12
by: torbs | last post by:
Hi I have a a function with several methods. For simplicity it looks a bit like this: super.prototype.aProperty="HELLO"; super.prototype.returnValue = function () { return 2;
3
by: Jayman777 | last post by:
Hello, I am using PHP 4.4.1 and am having problems retrieving an object from an array of objects and then calling a method on it. Here are two simple classes that I am using: class Day...
4
by: Edwin Gomez | last post by:
I'm a C# developer and I'm new to Python. I would like to know if the concept of Asynchronous call-backs exists in Python. Basically what I mean is that I dispatch a thread and when the thread...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.