473,324 Members | 2,567 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,324 software developers and data experts.

newbie Java question: 2 files in one project

I am learning Java. I am using NetBeans. I created a new project named TestCircle using the default package name provided by NetBeans, which is the same as the file name but all in lower case. The file is TestCircle.java:

Expand|Select|Wrap|Line Numbers
  1. // TestCircle.java
  2. package testcircle;
  3. public class TestCircle {
  4.     public static void main(String[] args) {        
  5.         //Circle myCircle = new Circle();
  6.     }
  7. }
Then I right-clicked the project name and added a new class file named Circle:
Expand|Select|Wrap|Line Numbers
  1. // Circle.java
  2. public class Circle {   
  3.     int radius;   
  4.     // constructor
  5.     Circle(){
  6.     }
  7. }
I right-click the project and do a Clean and Build. There are no errors.


But when I un-comment the line:
Expand|Select|Wrap|Line Numbers
  1. //Circle myCircle = new Circle();
  2.  
I get a compile error. Here is part of the compile output:
Expand|Select|Wrap|Line Numbers
  1. Compiling 2 source files to C:\Users\JohannFu\Documents\NetBeansProjects\TestCircle\build\classes
  2. C:\Users\JohannFu\Documents\NetBeansProjects\TestCircle\src\testcircle\TestCircle.java:6: cannot find symbol
  3. symbol  : class Circle
  4. location: class testcircle.TestCircle
  5.         Circle myCircle = new Circle();
  6. C:\Users\JohannFu\Documents\NetBeansProjects\TestCircle\src\testcircle\TestCircle.java:6: cannot find symbol
  7. symbol  : class Circle
  8. location: class testcircle.TestCircle
  9.         Circle myCircle = new Circle();
  10. 2 errors
So it looks like as soon as I try to instantiate a Circle object, the TestCircle class cannot find the Circle class!
What am I doing wrong? Thanks for any help!
Oct 7 '11 #1
1 1908
Frinavale
9,735 Expert Mod 8TB
You need to include a reference to your first Circle class into your TestCircle class in order to be able to use it in your TestCircle class.

Or maybe put them in the same namespace...not sure how this works in Java though...

Aha a Java Package

I think that if you import Circle into TestClass you should be golden.

-Frinny
Oct 7 '11 #2

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

Similar topics

3
by: StealthMonkey | last post by:
Let me prefix this by saying that I know next to nothing about Java (so please try to keep explainations simple). I use PHP for my server-side web programming. Here is my dilemma: I need a...
0
by: Petterson Mikael | last post by:
Hi, I am using Solaris 8 and JDK1.4.1 I will generate java source files from XML. I am thinking of using JAXB package. As input I have my XML and DTD. I setup "Java Web Services Developer Pack...
5
by: Henry | last post by:
HTML is an acronym for Hyper Text Markup Language. But why is it hyper? Too much java . . . http://takeoff.to/henry
14
by: Mick | last post by:
I wrote a C# program that interfaces with a data vendor over the web using an API they supplied and their examples in C#. Now I have another data vendor's API and example that I want to add to...
5
by: schizoid_man | last post by:
Hi, I have a decent amount of programming experience in C/C++ and have recently heard very good things about C#. So I decided to take a look... The lexical elements and language layout make...
0
by: napi | last post by:
We are pleased to announce the release of version '1.5.0' of AMPC (Axiomatic Multi-Platform C) C to Java class files compiler suite. It is Write Once Run Anywhere (WORA) with C. Detailed info...
6
by: napi | last post by:
C to Java Class Files ------------------------------- We are pleased to announce the release of version '1.5.1' of AMPC (Axiomatic Multi-Platform C) C to Java class files compiler suite. It is...
0
by: imghani | last post by:
Hi all, I am going to prepare a installer in Visual Studio for a project using Java and Oracle. First, i want to know that is it possible or not? Secondly, whether i can check the following...
0
by: Albert-jan Roskam | last post by:
Hi John, Thanks! Using a higher xlrd version did the trick! Regarding your other remarks: -yep, input files with multiple sheets don't work yet. I kinda repressed that ;-) Spss outputs only...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.