• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with Multiple Classes, Objects, and Methods in Java  RSS feed

 
Timothy Han
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm learning Java programming through a Youtube video. Int his video the topic is multiple classes, objects, and methods. In the video I was told to go into my IDE (Netbeans), to create a new class call tuna from my source package and name the newly created class tuna. So now I have two .java file types; one is MultipleClasses which contains my main method and the newly created class and method call simpleMessage in tuna.java.

Here is the class containing my main method call MultipleClasses.java file:


Here is my newly created class tuna.java file:


When I follow the video I input the code exactly and checked it for spelling or syntax errors, and I run the code in my Netbeans IDE I get this error build message;

run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
symbol: class tuna
location: class multipleclasses.MultipleClasses
at multipleclasses.MultipleClasses.main(MultipleClasses.java:11)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

What is going on here? I followed the instructional video exactly. How did it work for him, vene though he was using Eclipse?
 
Stefan Evans
Bartender
Posts: 1837
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! Welcome to the Ranch.

What video/tutorial are you following? It helps if we can trace back to the original source.
How old is this tutorial?

Right now it is failing because the class "tuna" is in a different package to "MultipleClasses"

My best suggestion for a fix would be
- move the tuna class to the same directory as MultipleClasses
- add the line "package multipleclasses" to the top of tuna.java

it should compile and run at that point.

Also when posting code, can you please UseCodeTags? It makes it much easier to read when you do
 
Timothy Han
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stefan,

Thank you for your prompt reply and help. The video that I'm learning this particular lesson from can be found here https://www.youtube.com/watch?v=XqTg2buXS5o&list=PLFE2CE09D83EE3E28&index=14

In the video he did not have to move or reallocate any files. He is using Eclipse and I am using Netbeans.

How do I move my files into the same directory?
 
Timothy Han
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stefan, I tried moving the tuna.java file into the multipleclasses folder where the MultipleClasses.java file is and I still get an error build message in my Netbeans IDE saying:

run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: multipleclasses.tuna
at multipleclasses.MultipleClasses.main(MultipleClasses.java:11)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Timothy, welcome again. In future, please BeForthrightWhenCrossPostingToOtherSites
http://www.java-forums.org/new-java/94838-help-multiple-classes-objects-methods-java.html
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Timothy Han wrote:In the video I was told to go into my IDE (Netbeans)
In the video he did not have to move or reallocate any files. He is using Eclipse and I am using Netbeans.

Likely you have been told that too early. I encourage you to read this << link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!