Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: begginer, cant fix bug

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default begginer, cant fix bug

    Hello, how can I fix this bug:

    Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
    symbol: class tuna
    location: class apples.Apples

    The code is:

     
    package apples;
     
     
     
    import java.util.Scanner;
     
    public class Apples {
     
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            // TODO code application logic here
            Scanner input=new Scanner(System.in);
            tuna tunaObject = new tuna ();
            System.out.println("Enter your name here:");
            String name = input.nextLine();
            tunaObject.simpleMessage(name);


    Thanks!


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: begginer, cant fix bug

    Your error says it all: the code has no idea what tuna is. Where is the tuna class defined? (Btw, it should be Tuna, not tuna).
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. The Following User Says Thank You to KevinWorkman For This Useful Post:

    Inovan (October 2nd, 2014)

  4. #3
    Junior Member
    Join Date
    Jul 2014
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: begginer, cant fix bug

    thank you, I fixed tuna with Tuna. Here is class Tuna:

     
    package Tuna;
     
     
    public class Tuna {
     
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            // TODO code application logic here
        public void simpleMessage(String name)
        {
            System.out.println("hello " +name);
        }
     
    }

  5. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: begginer, cant fix bug

    Is your error gone now?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. #5
    Junior Member
    Join Date
    Jul 2014
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: begginer, cant fix bug

    No it's not gone yet, but I'm still digging. THX

  7. #6
    Junior Member
    Join Date
    Jul 2014
    Posts
    3
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: begginer, cant fix bug

    Problem is creating a method in the main for the Tuna class, remove the main in Tuna and just write the method for the Tuna class should look like this:

    public class Tuna {
     
    	    public void simpleMessage(String name)
    	    {
    	        System.out.println("hello " + name);
    	    }
    }

    And run apples and it should work Hope this helps. Also this is my first time helping someone did i do it right or did i just give the answer away, should i explain it.
    Last edited by mrc0ver; October 4th, 2014 at 04:02 AM.

  8. The Following User Says Thank You to mrc0ver For This Useful Post:

    Inovan (October 4th, 2014)

  9. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: begginer, cant fix bug

    I would guess that the actual problem is caused by the Tuna class not being imported, but without an MCVE we're just guessing.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. HW BEGGINER HELP !
    By begginerJava in forum Object Oriented Programming
    Replies: 5
    Last Post: April 14th, 2014, 11:54 AM
  2. How to fix this bug with my calculator program?
    By abstractmind in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 23rd, 2013, 05:21 AM
  3. Java Help for a begginer
    By miller4103 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 15th, 2013, 09:00 PM
  4. Begginer Java - Bug in my code?
    By rk2010 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 7th, 2012, 08:12 AM
  5. help im a begginer
    By ivankov2 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 24th, 2011, 07:33 AM