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.
java package
add a comment |
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.
java package
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
add a comment |
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.
java package
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
java package
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
add a comment |
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
add a comment |
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
add a comment |
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
add a comment |
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
add a comment |
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
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
edited Nov 10 at 4:02
answered Nov 10 at 3:43
NiksVij
386
386
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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