Run Java Code without a package in Eclipse IDE
up vote
0
down vote
favorite
I want to run my code without creating a package in java eclipse IDE.
But when I do so it is showing error :
Must declare a named package because this compilation unit is associated to the named module 'Games'
java eclipse java-package
add a comment |
up vote
0
down vote
favorite
I want to run my code without creating a package in java eclipse IDE.
But when I do so it is showing error :
Must declare a named package because this compilation unit is associated to the named module 'Games'
java eclipse java-package
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to run my code without creating a package in java eclipse IDE.
But when I do so it is showing error :
Must declare a named package because this compilation unit is associated to the named module 'Games'
java eclipse java-package
I want to run my code without creating a package in java eclipse IDE.
But when I do so it is showing error :
Must declare a named package because this compilation unit is associated to the named module 'Games'
java eclipse java-package
java eclipse java-package
edited Nov 10 at 20:41
rishabh agarwal
711316
711316
asked Nov 10 at 17:48
Ramo
83
83
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
up vote
0
down vote
accepted
You are using the Java Platform Module System (JPMS) which requires not to use the default/unnamed package.
In the default package delete the file module-info.java
to not use JPMS and to be able to have code in the default package.
1
Got it sir ... Thks a lot !!!
– Ramo
Nov 11 at 14:18
add a comment |
up vote
1
down vote
Just right click on the project folder -> New -> Package. Once the package is made, move all your classes into it.
but I don't want to create any package ... I want to make it default !!!
– Ramo
Nov 10 at 17:57
add a comment |
up vote
0
down vote
Double click on the error icon at the line number ->move to default package option.
Make sure the classes are (public or protected) to be used in different packages.
sry bro ... didn't get it ! Can u explain please ?
– Ramo
Nov 10 at 18:15
When you remove the package statement from your code, eclipse shows error on the line number right? When you double click the error symbol, it also shows the suggestions to correct the error. Among them, choose "move to default package" option
– Vishnu V
Nov 10 at 18:17
but i doubled click on error symbol but it showing nothing !
– Ramo
Nov 10 at 18:20
Try keeping the mouse pointer on the error symbol without clicking on it and see if it suggests. In my eclipse ide it does.
– Vishnu V
Nov 10 at 18:21
sry bro nothing happen !
– Ramo
Nov 10 at 18:23
|
show 3 more comments
up vote
0
down vote
In the file in question, right click to get the context menu. Select "Refactor->Move". The resultant dialog will have the (default package) into which the source file may be placed.
Also, be sure to not have a package definition line at the start of the source file.
Please note that the use of the default
package is generally discouraged, but there are time I still use it (primarily for printing copyright/version information).
There are also options for turning on hidden/suppressed parent packages, but I think the Refactor approach is the most clean.
add a comment |
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
You are using the Java Platform Module System (JPMS) which requires not to use the default/unnamed package.
In the default package delete the file module-info.java
to not use JPMS and to be able to have code in the default package.
1
Got it sir ... Thks a lot !!!
– Ramo
Nov 11 at 14:18
add a comment |
up vote
0
down vote
accepted
You are using the Java Platform Module System (JPMS) which requires not to use the default/unnamed package.
In the default package delete the file module-info.java
to not use JPMS and to be able to have code in the default package.
1
Got it sir ... Thks a lot !!!
– Ramo
Nov 11 at 14:18
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You are using the Java Platform Module System (JPMS) which requires not to use the default/unnamed package.
In the default package delete the file module-info.java
to not use JPMS and to be able to have code in the default package.
You are using the Java Platform Module System (JPMS) which requires not to use the default/unnamed package.
In the default package delete the file module-info.java
to not use JPMS and to be able to have code in the default package.
edited Nov 11 at 8:31
answered Nov 11 at 8:23
howlger
9,61551636
9,61551636
1
Got it sir ... Thks a lot !!!
– Ramo
Nov 11 at 14:18
add a comment |
1
Got it sir ... Thks a lot !!!
– Ramo
Nov 11 at 14:18
1
1
Got it sir ... Thks a lot !!!
– Ramo
Nov 11 at 14:18
Got it sir ... Thks a lot !!!
– Ramo
Nov 11 at 14:18
add a comment |
up vote
1
down vote
Just right click on the project folder -> New -> Package. Once the package is made, move all your classes into it.
but I don't want to create any package ... I want to make it default !!!
– Ramo
Nov 10 at 17:57
add a comment |
up vote
1
down vote
Just right click on the project folder -> New -> Package. Once the package is made, move all your classes into it.
but I don't want to create any package ... I want to make it default !!!
– Ramo
Nov 10 at 17:57
add a comment |
up vote
1
down vote
up vote
1
down vote
Just right click on the project folder -> New -> Package. Once the package is made, move all your classes into it.
Just right click on the project folder -> New -> Package. Once the package is made, move all your classes into it.
answered Nov 10 at 17:54
Naeem Khan
529
529
but I don't want to create any package ... I want to make it default !!!
– Ramo
Nov 10 at 17:57
add a comment |
but I don't want to create any package ... I want to make it default !!!
– Ramo
Nov 10 at 17:57
but I don't want to create any package ... I want to make it default !!!
– Ramo
Nov 10 at 17:57
but I don't want to create any package ... I want to make it default !!!
– Ramo
Nov 10 at 17:57
add a comment |
up vote
0
down vote
Double click on the error icon at the line number ->move to default package option.
Make sure the classes are (public or protected) to be used in different packages.
sry bro ... didn't get it ! Can u explain please ?
– Ramo
Nov 10 at 18:15
When you remove the package statement from your code, eclipse shows error on the line number right? When you double click the error symbol, it also shows the suggestions to correct the error. Among them, choose "move to default package" option
– Vishnu V
Nov 10 at 18:17
but i doubled click on error symbol but it showing nothing !
– Ramo
Nov 10 at 18:20
Try keeping the mouse pointer on the error symbol without clicking on it and see if it suggests. In my eclipse ide it does.
– Vishnu V
Nov 10 at 18:21
sry bro nothing happen !
– Ramo
Nov 10 at 18:23
|
show 3 more comments
up vote
0
down vote
Double click on the error icon at the line number ->move to default package option.
Make sure the classes are (public or protected) to be used in different packages.
sry bro ... didn't get it ! Can u explain please ?
– Ramo
Nov 10 at 18:15
When you remove the package statement from your code, eclipse shows error on the line number right? When you double click the error symbol, it also shows the suggestions to correct the error. Among them, choose "move to default package" option
– Vishnu V
Nov 10 at 18:17
but i doubled click on error symbol but it showing nothing !
– Ramo
Nov 10 at 18:20
Try keeping the mouse pointer on the error symbol without clicking on it and see if it suggests. In my eclipse ide it does.
– Vishnu V
Nov 10 at 18:21
sry bro nothing happen !
– Ramo
Nov 10 at 18:23
|
show 3 more comments
up vote
0
down vote
up vote
0
down vote
Double click on the error icon at the line number ->move to default package option.
Make sure the classes are (public or protected) to be used in different packages.
Double click on the error icon at the line number ->move to default package option.
Make sure the classes are (public or protected) to be used in different packages.
answered Nov 10 at 18:05
Vishnu V
344
344
sry bro ... didn't get it ! Can u explain please ?
– Ramo
Nov 10 at 18:15
When you remove the package statement from your code, eclipse shows error on the line number right? When you double click the error symbol, it also shows the suggestions to correct the error. Among them, choose "move to default package" option
– Vishnu V
Nov 10 at 18:17
but i doubled click on error symbol but it showing nothing !
– Ramo
Nov 10 at 18:20
Try keeping the mouse pointer on the error symbol without clicking on it and see if it suggests. In my eclipse ide it does.
– Vishnu V
Nov 10 at 18:21
sry bro nothing happen !
– Ramo
Nov 10 at 18:23
|
show 3 more comments
sry bro ... didn't get it ! Can u explain please ?
– Ramo
Nov 10 at 18:15
When you remove the package statement from your code, eclipse shows error on the line number right? When you double click the error symbol, it also shows the suggestions to correct the error. Among them, choose "move to default package" option
– Vishnu V
Nov 10 at 18:17
but i doubled click on error symbol but it showing nothing !
– Ramo
Nov 10 at 18:20
Try keeping the mouse pointer on the error symbol without clicking on it and see if it suggests. In my eclipse ide it does.
– Vishnu V
Nov 10 at 18:21
sry bro nothing happen !
– Ramo
Nov 10 at 18:23
sry bro ... didn't get it ! Can u explain please ?
– Ramo
Nov 10 at 18:15
sry bro ... didn't get it ! Can u explain please ?
– Ramo
Nov 10 at 18:15
When you remove the package statement from your code, eclipse shows error on the line number right? When you double click the error symbol, it also shows the suggestions to correct the error. Among them, choose "move to default package" option
– Vishnu V
Nov 10 at 18:17
When you remove the package statement from your code, eclipse shows error on the line number right? When you double click the error symbol, it also shows the suggestions to correct the error. Among them, choose "move to default package" option
– Vishnu V
Nov 10 at 18:17
but i doubled click on error symbol but it showing nothing !
– Ramo
Nov 10 at 18:20
but i doubled click on error symbol but it showing nothing !
– Ramo
Nov 10 at 18:20
Try keeping the mouse pointer on the error symbol without clicking on it and see if it suggests. In my eclipse ide it does.
– Vishnu V
Nov 10 at 18:21
Try keeping the mouse pointer on the error symbol without clicking on it and see if it suggests. In my eclipse ide it does.
– Vishnu V
Nov 10 at 18:21
sry bro nothing happen !
– Ramo
Nov 10 at 18:23
sry bro nothing happen !
– Ramo
Nov 10 at 18:23
|
show 3 more comments
up vote
0
down vote
In the file in question, right click to get the context menu. Select "Refactor->Move". The resultant dialog will have the (default package) into which the source file may be placed.
Also, be sure to not have a package definition line at the start of the source file.
Please note that the use of the default
package is generally discouraged, but there are time I still use it (primarily for printing copyright/version information).
There are also options for turning on hidden/suppressed parent packages, but I think the Refactor approach is the most clean.
add a comment |
up vote
0
down vote
In the file in question, right click to get the context menu. Select "Refactor->Move". The resultant dialog will have the (default package) into which the source file may be placed.
Also, be sure to not have a package definition line at the start of the source file.
Please note that the use of the default
package is generally discouraged, but there are time I still use it (primarily for printing copyright/version information).
There are also options for turning on hidden/suppressed parent packages, but I think the Refactor approach is the most clean.
add a comment |
up vote
0
down vote
up vote
0
down vote
In the file in question, right click to get the context menu. Select "Refactor->Move". The resultant dialog will have the (default package) into which the source file may be placed.
Also, be sure to not have a package definition line at the start of the source file.
Please note that the use of the default
package is generally discouraged, but there are time I still use it (primarily for printing copyright/version information).
There are also options for turning on hidden/suppressed parent packages, but I think the Refactor approach is the most clean.
In the file in question, right click to get the context menu. Select "Refactor->Move". The resultant dialog will have the (default package) into which the source file may be placed.
Also, be sure to not have a package definition line at the start of the source file.
Please note that the use of the default
package is generally discouraged, but there are time I still use it (primarily for printing copyright/version information).
There are also options for turning on hidden/suppressed parent packages, but I think the Refactor approach is the most clean.
answered Nov 10 at 20:55
KevinO
3,04131628
3,04131628
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%2f53241774%2frun-java-code-without-a-package-in-eclipse-ide%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