Package Say does not exist









up vote
1
down vote

favorite












I was coding in java to test out packages. I have a folder called Demo inside Demo I have 2 folders, one called Say and the other folder Called OtherMainClass.



in Say folder I have a class called SayClass.java
here is code:



package Say;

public class SayClass
public void sayTestMessage()
System.out.println("This is a test");




in OtherMainClass folder I have a file called OtherMain.java here is code:



import Say.*;

public class OtherMain
public static void main(String args)
SayClass s = new SayClass();

s.sayTestMessage();




when I compile OtherMain.java I get the following error:



OtherMain.java:1: error: package Say does not exist
import Say.*;
^
OtherMain.java:5: error: cannot find symbol
SayClass s = new SayClass();
^
symbol: class SayClass
location: class OtherMain
OtherMain.java:5: error: cannot find symbol
SayClass s = new SayClass();
^
symbol: class SayClass
location: class OtherMain
3 errors


Why can't java find the Say package? If I am understanding packages wrong then please explain what I am doing wrong and what is right.










share|improve this question



















  • 1




    Where you compile from matters; package names follow the directory names.
    – Dave Newton
    Nov 10 at 3:54










  • @failedProgrammer I'm not sure what you're trying to say--if they're having problems with this, Maven/Ant/Gradle certainly won't help. There's no need to jump to a build/dependency system to understand package naming or directory conventions.
    – Dave Newton
    Nov 10 at 3:55














up vote
1
down vote

favorite












I was coding in java to test out packages. I have a folder called Demo inside Demo I have 2 folders, one called Say and the other folder Called OtherMainClass.



in Say folder I have a class called SayClass.java
here is code:



package Say;

public class SayClass
public void sayTestMessage()
System.out.println("This is a test");




in OtherMainClass folder I have a file called OtherMain.java here is code:



import Say.*;

public class OtherMain
public static void main(String args)
SayClass s = new SayClass();

s.sayTestMessage();




when I compile OtherMain.java I get the following error:



OtherMain.java:1: error: package Say does not exist
import Say.*;
^
OtherMain.java:5: error: cannot find symbol
SayClass s = new SayClass();
^
symbol: class SayClass
location: class OtherMain
OtherMain.java:5: error: cannot find symbol
SayClass s = new SayClass();
^
symbol: class SayClass
location: class OtherMain
3 errors


Why can't java find the Say package? If I am understanding packages wrong then please explain what I am doing wrong and what is right.










share|improve this question



















  • 1




    Where you compile from matters; package names follow the directory names.
    – Dave Newton
    Nov 10 at 3:54










  • @failedProgrammer I'm not sure what you're trying to say--if they're having problems with this, Maven/Ant/Gradle certainly won't help. There's no need to jump to a build/dependency system to understand package naming or directory conventions.
    – Dave Newton
    Nov 10 at 3:55












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I was coding in java to test out packages. I have a folder called Demo inside Demo I have 2 folders, one called Say and the other folder Called OtherMainClass.



in Say folder I have a class called SayClass.java
here is code:



package Say;

public class SayClass
public void sayTestMessage()
System.out.println("This is a test");




in OtherMainClass folder I have a file called OtherMain.java here is code:



import Say.*;

public class OtherMain
public static void main(String args)
SayClass s = new SayClass();

s.sayTestMessage();




when I compile OtherMain.java I get the following error:



OtherMain.java:1: error: package Say does not exist
import Say.*;
^
OtherMain.java:5: error: cannot find symbol
SayClass s = new SayClass();
^
symbol: class SayClass
location: class OtherMain
OtherMain.java:5: error: cannot find symbol
SayClass s = new SayClass();
^
symbol: class SayClass
location: class OtherMain
3 errors


Why can't java find the Say package? If I am understanding packages wrong then please explain what I am doing wrong and what is right.










share|improve this question















I was coding in java to test out packages. I have a folder called Demo inside Demo I have 2 folders, one called Say and the other folder Called OtherMainClass.



in Say folder I have a class called SayClass.java
here is code:



package Say;

public class SayClass
public void sayTestMessage()
System.out.println("This is a test");




in OtherMainClass folder I have a file called OtherMain.java here is code:



import Say.*;

public class OtherMain
public static void main(String args)
SayClass s = new SayClass();

s.sayTestMessage();




when I compile OtherMain.java I get the following error:



OtherMain.java:1: error: package Say does not exist
import Say.*;
^
OtherMain.java:5: error: cannot find symbol
SayClass s = new SayClass();
^
symbol: class SayClass
location: class OtherMain
OtherMain.java:5: error: cannot find symbol
SayClass s = new SayClass();
^
symbol: class SayClass
location: class OtherMain
3 errors


Why can't java find the Say package? If I am understanding packages wrong then please explain what I am doing wrong and what is right.







java package






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 3:53









Dave Newton

138k18208253




138k18208253










asked Nov 10 at 3:26









Ujwal Joshi

61




61







  • 1




    Where you compile from matters; package names follow the directory names.
    – Dave Newton
    Nov 10 at 3:54










  • @failedProgrammer I'm not sure what you're trying to say--if they're having problems with this, Maven/Ant/Gradle certainly won't help. There's no need to jump to a build/dependency system to understand package naming or directory conventions.
    – Dave Newton
    Nov 10 at 3:55












  • 1




    Where you compile from matters; package names follow the directory names.
    – Dave Newton
    Nov 10 at 3:54










  • @failedProgrammer I'm not sure what you're trying to say--if they're having problems with this, Maven/Ant/Gradle certainly won't help. There's no need to jump to a build/dependency system to understand package naming or directory conventions.
    – Dave Newton
    Nov 10 at 3:55







1




1




Where you compile from matters; package names follow the directory names.
– Dave Newton
Nov 10 at 3:54




Where you compile from matters; package names follow the directory names.
– Dave Newton
Nov 10 at 3:54












@failedProgrammer I'm not sure what you're trying to say--if they're having problems with this, Maven/Ant/Gradle certainly won't help. There's no need to jump to a build/dependency system to understand package naming or directory conventions.
– Dave Newton
Nov 10 at 3:55




@failedProgrammer I'm not sure what you're trying to say--if they're having problems with this, Maven/Ant/Gradle certainly won't help. There's no need to jump to a build/dependency system to understand package naming or directory conventions.
– Dave Newton
Nov 10 at 3:55












1 Answer
1






active

oldest

votes

















up vote
0
down vote













You have to use below statement while importing in OtherMain



import Demo.Say.SayClass


Also package name convention is lowercase so kindly refactor your code to use from Say to say and Demo to demo .
And also while creating SayClass use package demo.say . So your code should be like



package demo.say;
public class SayClass
public void sayTestMessage()
System.out.println("This is a test");




after you are done renaming all the packages to lowercase then you can use



import demo.say.SayClass 


or



import demo.say.*


in OtherMain class



Suggestions:
Its better to use standard community version of IDEs like Intellij Idea, Eclipse, etc which automatically takes care of package naming, convention and lots of other house-care stuff



and go through the java naming convention docs/tutorials like https://www.javatpoint.com/java-naming-conventions






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235764%2fpackage-say-does-not-exist%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    You have to use below statement while importing in OtherMain



    import Demo.Say.SayClass


    Also package name convention is lowercase so kindly refactor your code to use from Say to say and Demo to demo .
    And also while creating SayClass use package demo.say . So your code should be like



    package demo.say;
    public class SayClass
    public void sayTestMessage()
    System.out.println("This is a test");




    after you are done renaming all the packages to lowercase then you can use



    import demo.say.SayClass 


    or



    import demo.say.*


    in OtherMain class



    Suggestions:
    Its better to use standard community version of IDEs like Intellij Idea, Eclipse, etc which automatically takes care of package naming, convention and lots of other house-care stuff



    and go through the java naming convention docs/tutorials like https://www.javatpoint.com/java-naming-conventions






    share|improve this answer


























      up vote
      0
      down vote













      You have to use below statement while importing in OtherMain



      import Demo.Say.SayClass


      Also package name convention is lowercase so kindly refactor your code to use from Say to say and Demo to demo .
      And also while creating SayClass use package demo.say . So your code should be like



      package demo.say;
      public class SayClass
      public void sayTestMessage()
      System.out.println("This is a test");




      after you are done renaming all the packages to lowercase then you can use



      import demo.say.SayClass 


      or



      import demo.say.*


      in OtherMain class



      Suggestions:
      Its better to use standard community version of IDEs like Intellij Idea, Eclipse, etc which automatically takes care of package naming, convention and lots of other house-care stuff



      and go through the java naming convention docs/tutorials like https://www.javatpoint.com/java-naming-conventions






      share|improve this answer
























        up vote
        0
        down vote










        up vote
        0
        down vote









        You have to use below statement while importing in OtherMain



        import Demo.Say.SayClass


        Also package name convention is lowercase so kindly refactor your code to use from Say to say and Demo to demo .
        And also while creating SayClass use package demo.say . So your code should be like



        package demo.say;
        public class SayClass
        public void sayTestMessage()
        System.out.println("This is a test");




        after you are done renaming all the packages to lowercase then you can use



        import demo.say.SayClass 


        or



        import demo.say.*


        in OtherMain class



        Suggestions:
        Its better to use standard community version of IDEs like Intellij Idea, Eclipse, etc which automatically takes care of package naming, convention and lots of other house-care stuff



        and go through the java naming convention docs/tutorials like https://www.javatpoint.com/java-naming-conventions






        share|improve this answer














        You have to use below statement while importing in OtherMain



        import Demo.Say.SayClass


        Also package name convention is lowercase so kindly refactor your code to use from Say to say and Demo to demo .
        And also while creating SayClass use package demo.say . So your code should be like



        package demo.say;
        public class SayClass
        public void sayTestMessage()
        System.out.println("This is a test");




        after you are done renaming all the packages to lowercase then you can use



        import demo.say.SayClass 


        or



        import demo.say.*


        in OtherMain class



        Suggestions:
        Its better to use standard community version of IDEs like Intellij Idea, Eclipse, etc which automatically takes care of package naming, convention and lots of other house-care stuff



        and go through the java naming convention docs/tutorials like https://www.javatpoint.com/java-naming-conventions







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 10 at 4:02

























        answered Nov 10 at 3:43









        NiksVij

        386




        386



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235764%2fpackage-say-does-not-exist%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kleinkühnau

            Makov (Slowakei)

            Deutsches Schauspielhaus