Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Help with Multiple Classes, Objects, and Methods in Java

 
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?
 
Bartender
Posts: 1845
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)
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • 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
 
Sheriff
Posts: 7657
522
Mac OS X VI Editor BSD Linux
  • 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
 
Did you ever grow anything in the garden of your mind? - Fred Rogers. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic