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'









share|improve this question




























    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'









    share|improve this question


























      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'









      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 20:41









      rishabh agarwal

      694316




      694316










      asked Nov 10 at 17:48









      Ramo

      83




      83
























          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.






          share|improve this answer



















          • 1




            Got it sir ... Thks a lot !!!
            – Ramo
            Nov 11 at 14:18


















          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.






          share|improve this answer





















          • but I don't want to create any package ... I want to make it default !!!
            – Ramo
            Nov 10 at 17:57


















          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.






          share|improve this answer





















          • 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


















          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).



          enter image description here



          enter image description here



          There are also options for turning on hidden/suppressed parent packages, but I think the Refactor approach is the most clean.






          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%2f53241774%2frun-java-code-without-a-package-in-eclipse-ide%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            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.






            share|improve this answer



















            • 1




              Got it sir ... Thks a lot !!!
              – Ramo
              Nov 11 at 14:18















            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.






            share|improve this answer



















            • 1




              Got it sir ... Thks a lot !!!
              – Ramo
              Nov 11 at 14:18













            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.






            share|improve this answer














            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.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 11 at 8:31

























            answered Nov 11 at 8:23









            howlger

            9,51251636




            9,51251636








            • 1




              Got it sir ... Thks a lot !!!
              – Ramo
              Nov 11 at 14:18














            • 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












            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.






            share|improve this answer





















            • but I don't want to create any package ... I want to make it default !!!
              – Ramo
              Nov 10 at 17:57















            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.






            share|improve this answer





















            • but I don't want to create any package ... I want to make it default !!!
              – Ramo
              Nov 10 at 17:57













            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.






            share|improve this answer












            Just right click on the project folder -> New -> Package. Once the package is made, move all your classes into it.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 10 at 17:54









            Naeem Khan

            479




            479












            • 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




            but I don't want to create any package ... I want to make it default !!!
            – Ramo
            Nov 10 at 17:57










            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.






            share|improve this answer





















            • 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















            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.






            share|improve this answer





















            • 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













            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.






            share|improve this answer












            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.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            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


















            • 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










            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).



            enter image description here



            enter image description here



            There are also options for turning on hidden/suppressed parent packages, but I think the Refactor approach is the most clean.






            share|improve this answer

























              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).



              enter image description here



              enter image description here



              There are also options for turning on hidden/suppressed parent packages, but I think the Refactor approach is the most clean.






              share|improve this answer























                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).



                enter image description here



                enter image description here



                There are also options for turning on hidden/suppressed parent packages, but I think the Refactor approach is the most clean.






                share|improve this answer












                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).



                enter image description here



                enter image description here



                There are also options for turning on hidden/suppressed parent packages, but I think the Refactor approach is the most clean.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 10 at 20:55









                KevinO

                3,01131627




                3,01131627






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    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





















































                    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

                    Florida Star v. B. J. F.

                    Danny Elfman

                    Lugert, Oklahoma