How to save Java Project from IntelliJ IDEA to Git repo so it will build on another PC after cloning?











up vote
1
down vote

favorite












I'm building a simple calculator app from a tutorial/class on Pluralsight (Java Fundamentals class), which starts with a Main.java file, and adds a class file later, MathEquation.java.



I created a Git repo to track my progress, and uploaded to Github: JavaFundamentalsClass. I used GitIgnore.IO to find a Java IntelliJ .gitignore file, and everything seemed to be working fine on the original PC I was using.



However, after switching over to a different PC, with a fresh install of IDEA, I cloned down the repo from Github, and found that the project would not build and/or run. I get this error:




"C:Program FilesRedHatjava-1.8.0-openjdk-1.8.0.191-1binjava.exe" -Dfile.encoding=windows-1252 -jar ""



Error: Unable to access jarfile



Process finished with exit code 1




I suspect that there is something in the .gitigore file that is keeping some of the project, dependency, or build information from being saved in the repo that keeps IDEA from having all the info it needs to build and run the Main.java correctly.



Can anyone help? You should be able to download the project from the repo linked above in it's currently broken state, including the .gitignore file.





Additional Info



I wiped my repo clean and recloned and I forgot, originally it doesn't even give me the run button (it is grayed out). I had to do a procedure with "Add Configuration" from a search I did for that to show up to get the error above.



Also, I did install java from the OpenJDK, rather than oracle. I figured with Oracle cutting off commercial development maybe start the switch now as I'm learning, but maybe that's the issue (normal Java on my other PC).





It's working, but...



First thing - Intellij needs to know where Java is. It appears that if the SDK/JDK is not installed prior to Intellij, you will need to tell it where Java is after installing. Or if you use OpenJDK instead of Oracle Java SDK. You can do that at View/Open Library Settings, under Platform Settings / SDKs (select the JDK home path).



Then, after setting up Java, I am able to get everything working in Intellij IDEA if I find the Main.java file, right-click, and choose "Run main.main()". This runs the program okay, and also creates a Main configuration in the Run/Debug configuration area, and finally the "Run" button becomes available.



So I can get it working, but if I wipe all the files and clone it fresh from the remote repo, I have to go through running the Main.java file directly again to recreate the configuration.



So, this still doesn't answer my original question. Why doesn't this configuration get saved in the repo? What file is this information saved in? Is there something in the .gitignore file that is keeping this information from being saved to the repo?










share|improve this question




























    up vote
    1
    down vote

    favorite












    I'm building a simple calculator app from a tutorial/class on Pluralsight (Java Fundamentals class), which starts with a Main.java file, and adds a class file later, MathEquation.java.



    I created a Git repo to track my progress, and uploaded to Github: JavaFundamentalsClass. I used GitIgnore.IO to find a Java IntelliJ .gitignore file, and everything seemed to be working fine on the original PC I was using.



    However, after switching over to a different PC, with a fresh install of IDEA, I cloned down the repo from Github, and found that the project would not build and/or run. I get this error:




    "C:Program FilesRedHatjava-1.8.0-openjdk-1.8.0.191-1binjava.exe" -Dfile.encoding=windows-1252 -jar ""



    Error: Unable to access jarfile



    Process finished with exit code 1




    I suspect that there is something in the .gitigore file that is keeping some of the project, dependency, or build information from being saved in the repo that keeps IDEA from having all the info it needs to build and run the Main.java correctly.



    Can anyone help? You should be able to download the project from the repo linked above in it's currently broken state, including the .gitignore file.





    Additional Info



    I wiped my repo clean and recloned and I forgot, originally it doesn't even give me the run button (it is grayed out). I had to do a procedure with "Add Configuration" from a search I did for that to show up to get the error above.



    Also, I did install java from the OpenJDK, rather than oracle. I figured with Oracle cutting off commercial development maybe start the switch now as I'm learning, but maybe that's the issue (normal Java on my other PC).





    It's working, but...



    First thing - Intellij needs to know where Java is. It appears that if the SDK/JDK is not installed prior to Intellij, you will need to tell it where Java is after installing. Or if you use OpenJDK instead of Oracle Java SDK. You can do that at View/Open Library Settings, under Platform Settings / SDKs (select the JDK home path).



    Then, after setting up Java, I am able to get everything working in Intellij IDEA if I find the Main.java file, right-click, and choose "Run main.main()". This runs the program okay, and also creates a Main configuration in the Run/Debug configuration area, and finally the "Run" button becomes available.



    So I can get it working, but if I wipe all the files and clone it fresh from the remote repo, I have to go through running the Main.java file directly again to recreate the configuration.



    So, this still doesn't answer my original question. Why doesn't this configuration get saved in the repo? What file is this information saved in? Is there something in the .gitignore file that is keeping this information from being saved to the repo?










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'm building a simple calculator app from a tutorial/class on Pluralsight (Java Fundamentals class), which starts with a Main.java file, and adds a class file later, MathEquation.java.



      I created a Git repo to track my progress, and uploaded to Github: JavaFundamentalsClass. I used GitIgnore.IO to find a Java IntelliJ .gitignore file, and everything seemed to be working fine on the original PC I was using.



      However, after switching over to a different PC, with a fresh install of IDEA, I cloned down the repo from Github, and found that the project would not build and/or run. I get this error:




      "C:Program FilesRedHatjava-1.8.0-openjdk-1.8.0.191-1binjava.exe" -Dfile.encoding=windows-1252 -jar ""



      Error: Unable to access jarfile



      Process finished with exit code 1




      I suspect that there is something in the .gitigore file that is keeping some of the project, dependency, or build information from being saved in the repo that keeps IDEA from having all the info it needs to build and run the Main.java correctly.



      Can anyone help? You should be able to download the project from the repo linked above in it's currently broken state, including the .gitignore file.





      Additional Info



      I wiped my repo clean and recloned and I forgot, originally it doesn't even give me the run button (it is grayed out). I had to do a procedure with "Add Configuration" from a search I did for that to show up to get the error above.



      Also, I did install java from the OpenJDK, rather than oracle. I figured with Oracle cutting off commercial development maybe start the switch now as I'm learning, but maybe that's the issue (normal Java on my other PC).





      It's working, but...



      First thing - Intellij needs to know where Java is. It appears that if the SDK/JDK is not installed prior to Intellij, you will need to tell it where Java is after installing. Or if you use OpenJDK instead of Oracle Java SDK. You can do that at View/Open Library Settings, under Platform Settings / SDKs (select the JDK home path).



      Then, after setting up Java, I am able to get everything working in Intellij IDEA if I find the Main.java file, right-click, and choose "Run main.main()". This runs the program okay, and also creates a Main configuration in the Run/Debug configuration area, and finally the "Run" button becomes available.



      So I can get it working, but if I wipe all the files and clone it fresh from the remote repo, I have to go through running the Main.java file directly again to recreate the configuration.



      So, this still doesn't answer my original question. Why doesn't this configuration get saved in the repo? What file is this information saved in? Is there something in the .gitignore file that is keeping this information from being saved to the repo?










      share|improve this question















      I'm building a simple calculator app from a tutorial/class on Pluralsight (Java Fundamentals class), which starts with a Main.java file, and adds a class file later, MathEquation.java.



      I created a Git repo to track my progress, and uploaded to Github: JavaFundamentalsClass. I used GitIgnore.IO to find a Java IntelliJ .gitignore file, and everything seemed to be working fine on the original PC I was using.



      However, after switching over to a different PC, with a fresh install of IDEA, I cloned down the repo from Github, and found that the project would not build and/or run. I get this error:




      "C:Program FilesRedHatjava-1.8.0-openjdk-1.8.0.191-1binjava.exe" -Dfile.encoding=windows-1252 -jar ""



      Error: Unable to access jarfile



      Process finished with exit code 1




      I suspect that there is something in the .gitigore file that is keeping some of the project, dependency, or build information from being saved in the repo that keeps IDEA from having all the info it needs to build and run the Main.java correctly.



      Can anyone help? You should be able to download the project from the repo linked above in it's currently broken state, including the .gitignore file.





      Additional Info



      I wiped my repo clean and recloned and I forgot, originally it doesn't even give me the run button (it is grayed out). I had to do a procedure with "Add Configuration" from a search I did for that to show up to get the error above.



      Also, I did install java from the OpenJDK, rather than oracle. I figured with Oracle cutting off commercial development maybe start the switch now as I'm learning, but maybe that's the issue (normal Java on my other PC).





      It's working, but...



      First thing - Intellij needs to know where Java is. It appears that if the SDK/JDK is not installed prior to Intellij, you will need to tell it where Java is after installing. Or if you use OpenJDK instead of Oracle Java SDK. You can do that at View/Open Library Settings, under Platform Settings / SDKs (select the JDK home path).



      Then, after setting up Java, I am able to get everything working in Intellij IDEA if I find the Main.java file, right-click, and choose "Run main.main()". This runs the program okay, and also creates a Main configuration in the Run/Debug configuration area, and finally the "Run" button becomes available.



      So I can get it working, but if I wipe all the files and clone it fresh from the remote repo, I have to go through running the Main.java file directly again to recreate the configuration.



      So, this still doesn't answer my original question. Why doesn't this configuration get saved in the repo? What file is this information saved in? Is there something in the .gitignore file that is keeping this information from being saved to the repo?







      java git intellij-idea






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 0:38

























      asked Nov 10 at 5:41









      LightCC

      1,158725




      1,158725
























          3 Answers
          3






          active

          oldest

          votes

















          up vote
          2
          down vote













          Look like you have a different java version on your second machine.




          • First of all, check your java version

          • Update the configuration of your project, right now it pointing to java 1.8


          https://github.com/LightCC/JavaFundamentalsClass/blob/master/.idea/misc.xml



          enter image description here



          enter image description here






          share|improve this answer





















          • This was partly right. I needed to show Intellij where Java was, using the "External Libraries" area. This was required after installing Java, whether I used Oracle's Java SDK or OpenJDK. But then I still need to find and run the "main" file directly to get the main "Run" button to become available. This also creates a configuration for "Main". Why doesn't this configuration get stored in the repo?
            – LightCC
            Nov 10 at 23:44


















          up vote
          1
          down vote













          I think it might be because of java not installed on the other PC you were trying. If it is installed just check whether the path mentioned has java executable file.






          share|improve this answer





















          • @LightCC do you have java installed on other PC? I see the issue is clearly not with IDE or .gitignore file.
            – Hrudayanath
            Nov 10 at 5:51










          • I have the java-1.8.0-openjdk-1.8.0.191-1 OpenJDK installed. Maybe this is the issue, but it is showing up in the project under the "External Libraries" area.
            – LightCC
            Nov 10 at 5:53










          • @LightCC can you try out jetbrains.com/help/idea/… , just try creating simple hello world program and try to run it, once done you can import the cloned project to IDE and run it.
            – Hrudayanath
            Nov 10 at 6:08










          • Once I point Intellij to Java, then I can build, but I have to find the file with the Main function and directly run it by right-clicking and selecting run. After I do that once, it adds a configuration for "Main" and the normal run button comes available. But if I delete all the files and reclone the repo, I'm back to the same situation - why doesn't that configuration for Main save to the repo?
            – LightCC
            Nov 10 at 23:48


















          up vote
          0
          down vote



          accepted











          1. The first part is ensuring Java is setup, and that Intellij IDEA knows where Java is, per the other answers, comments, and addendums to the question.


          2. The second part is setting up the run/debug configuration, per the "It's working but.." section of the question. This can be created automatically by right-clicking the file that has the main class to be run (usually Main()...), and selecting the "Run Main.main()" option (replacing Main and main() with the file and function which needs to be run)



          3. The final piece is that to get the run/debug configurations to save to the repo, you either need to:




            • Share the workspace.xml file (i.e. make sure this is not in the .gitignore file). However, there is a lot of user-specific stuff in that file, so it should normally be excluded from the repo.

            • Or, edit the configuration and checkmark the "Share" box in the upper right-hand corner (just right of the "Name" field). This will put the configuration into a separate folder inside the .idea folder, which should not be excluded from the repo by .gitignore.




          enter image description here



          enter image description here






          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%2f53236310%2fhow-to-save-java-project-from-intellij-idea-to-git-repo-so-it-will-build-on-anot%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            Look like you have a different java version on your second machine.




            • First of all, check your java version

            • Update the configuration of your project, right now it pointing to java 1.8


            https://github.com/LightCC/JavaFundamentalsClass/blob/master/.idea/misc.xml



            enter image description here



            enter image description here






            share|improve this answer





















            • This was partly right. I needed to show Intellij where Java was, using the "External Libraries" area. This was required after installing Java, whether I used Oracle's Java SDK or OpenJDK. But then I still need to find and run the "main" file directly to get the main "Run" button to become available. This also creates a configuration for "Main". Why doesn't this configuration get stored in the repo?
              – LightCC
              Nov 10 at 23:44















            up vote
            2
            down vote













            Look like you have a different java version on your second machine.




            • First of all, check your java version

            • Update the configuration of your project, right now it pointing to java 1.8


            https://github.com/LightCC/JavaFundamentalsClass/blob/master/.idea/misc.xml



            enter image description here



            enter image description here






            share|improve this answer





















            • This was partly right. I needed to show Intellij where Java was, using the "External Libraries" area. This was required after installing Java, whether I used Oracle's Java SDK or OpenJDK. But then I still need to find and run the "main" file directly to get the main "Run" button to become available. This also creates a configuration for "Main". Why doesn't this configuration get stored in the repo?
              – LightCC
              Nov 10 at 23:44













            up vote
            2
            down vote










            up vote
            2
            down vote









            Look like you have a different java version on your second machine.




            • First of all, check your java version

            • Update the configuration of your project, right now it pointing to java 1.8


            https://github.com/LightCC/JavaFundamentalsClass/blob/master/.idea/misc.xml



            enter image description here



            enter image description here






            share|improve this answer












            Look like you have a different java version on your second machine.




            • First of all, check your java version

            • Update the configuration of your project, right now it pointing to java 1.8


            https://github.com/LightCC/JavaFundamentalsClass/blob/master/.idea/misc.xml



            enter image description here



            enter image description here







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 10 at 7:38









            CodeWizard

            48.9k126688




            48.9k126688












            • This was partly right. I needed to show Intellij where Java was, using the "External Libraries" area. This was required after installing Java, whether I used Oracle's Java SDK or OpenJDK. But then I still need to find and run the "main" file directly to get the main "Run" button to become available. This also creates a configuration for "Main". Why doesn't this configuration get stored in the repo?
              – LightCC
              Nov 10 at 23:44


















            • This was partly right. I needed to show Intellij where Java was, using the "External Libraries" area. This was required after installing Java, whether I used Oracle's Java SDK or OpenJDK. But then I still need to find and run the "main" file directly to get the main "Run" button to become available. This also creates a configuration for "Main". Why doesn't this configuration get stored in the repo?
              – LightCC
              Nov 10 at 23:44
















            This was partly right. I needed to show Intellij where Java was, using the "External Libraries" area. This was required after installing Java, whether I used Oracle's Java SDK or OpenJDK. But then I still need to find and run the "main" file directly to get the main "Run" button to become available. This also creates a configuration for "Main". Why doesn't this configuration get stored in the repo?
            – LightCC
            Nov 10 at 23:44




            This was partly right. I needed to show Intellij where Java was, using the "External Libraries" area. This was required after installing Java, whether I used Oracle's Java SDK or OpenJDK. But then I still need to find and run the "main" file directly to get the main "Run" button to become available. This also creates a configuration for "Main". Why doesn't this configuration get stored in the repo?
            – LightCC
            Nov 10 at 23:44












            up vote
            1
            down vote













            I think it might be because of java not installed on the other PC you were trying. If it is installed just check whether the path mentioned has java executable file.






            share|improve this answer





















            • @LightCC do you have java installed on other PC? I see the issue is clearly not with IDE or .gitignore file.
              – Hrudayanath
              Nov 10 at 5:51










            • I have the java-1.8.0-openjdk-1.8.0.191-1 OpenJDK installed. Maybe this is the issue, but it is showing up in the project under the "External Libraries" area.
              – LightCC
              Nov 10 at 5:53










            • @LightCC can you try out jetbrains.com/help/idea/… , just try creating simple hello world program and try to run it, once done you can import the cloned project to IDE and run it.
              – Hrudayanath
              Nov 10 at 6:08










            • Once I point Intellij to Java, then I can build, but I have to find the file with the Main function and directly run it by right-clicking and selecting run. After I do that once, it adds a configuration for "Main" and the normal run button comes available. But if I delete all the files and reclone the repo, I'm back to the same situation - why doesn't that configuration for Main save to the repo?
              – LightCC
              Nov 10 at 23:48















            up vote
            1
            down vote













            I think it might be because of java not installed on the other PC you were trying. If it is installed just check whether the path mentioned has java executable file.






            share|improve this answer





















            • @LightCC do you have java installed on other PC? I see the issue is clearly not with IDE or .gitignore file.
              – Hrudayanath
              Nov 10 at 5:51










            • I have the java-1.8.0-openjdk-1.8.0.191-1 OpenJDK installed. Maybe this is the issue, but it is showing up in the project under the "External Libraries" area.
              – LightCC
              Nov 10 at 5:53










            • @LightCC can you try out jetbrains.com/help/idea/… , just try creating simple hello world program and try to run it, once done you can import the cloned project to IDE and run it.
              – Hrudayanath
              Nov 10 at 6:08










            • Once I point Intellij to Java, then I can build, but I have to find the file with the Main function and directly run it by right-clicking and selecting run. After I do that once, it adds a configuration for "Main" and the normal run button comes available. But if I delete all the files and reclone the repo, I'm back to the same situation - why doesn't that configuration for Main save to the repo?
              – LightCC
              Nov 10 at 23:48













            up vote
            1
            down vote










            up vote
            1
            down vote









            I think it might be because of java not installed on the other PC you were trying. If it is installed just check whether the path mentioned has java executable file.






            share|improve this answer












            I think it might be because of java not installed on the other PC you were trying. If it is installed just check whether the path mentioned has java executable file.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 10 at 5:45









            Hrudayanath

            1239




            1239












            • @LightCC do you have java installed on other PC? I see the issue is clearly not with IDE or .gitignore file.
              – Hrudayanath
              Nov 10 at 5:51










            • I have the java-1.8.0-openjdk-1.8.0.191-1 OpenJDK installed. Maybe this is the issue, but it is showing up in the project under the "External Libraries" area.
              – LightCC
              Nov 10 at 5:53










            • @LightCC can you try out jetbrains.com/help/idea/… , just try creating simple hello world program and try to run it, once done you can import the cloned project to IDE and run it.
              – Hrudayanath
              Nov 10 at 6:08










            • Once I point Intellij to Java, then I can build, but I have to find the file with the Main function and directly run it by right-clicking and selecting run. After I do that once, it adds a configuration for "Main" and the normal run button comes available. But if I delete all the files and reclone the repo, I'm back to the same situation - why doesn't that configuration for Main save to the repo?
              – LightCC
              Nov 10 at 23:48


















            • @LightCC do you have java installed on other PC? I see the issue is clearly not with IDE or .gitignore file.
              – Hrudayanath
              Nov 10 at 5:51










            • I have the java-1.8.0-openjdk-1.8.0.191-1 OpenJDK installed. Maybe this is the issue, but it is showing up in the project under the "External Libraries" area.
              – LightCC
              Nov 10 at 5:53










            • @LightCC can you try out jetbrains.com/help/idea/… , just try creating simple hello world program and try to run it, once done you can import the cloned project to IDE and run it.
              – Hrudayanath
              Nov 10 at 6:08










            • Once I point Intellij to Java, then I can build, but I have to find the file with the Main function and directly run it by right-clicking and selecting run. After I do that once, it adds a configuration for "Main" and the normal run button comes available. But if I delete all the files and reclone the repo, I'm back to the same situation - why doesn't that configuration for Main save to the repo?
              – LightCC
              Nov 10 at 23:48
















            @LightCC do you have java installed on other PC? I see the issue is clearly not with IDE or .gitignore file.
            – Hrudayanath
            Nov 10 at 5:51




            @LightCC do you have java installed on other PC? I see the issue is clearly not with IDE or .gitignore file.
            – Hrudayanath
            Nov 10 at 5:51












            I have the java-1.8.0-openjdk-1.8.0.191-1 OpenJDK installed. Maybe this is the issue, but it is showing up in the project under the "External Libraries" area.
            – LightCC
            Nov 10 at 5:53




            I have the java-1.8.0-openjdk-1.8.0.191-1 OpenJDK installed. Maybe this is the issue, but it is showing up in the project under the "External Libraries" area.
            – LightCC
            Nov 10 at 5:53












            @LightCC can you try out jetbrains.com/help/idea/… , just try creating simple hello world program and try to run it, once done you can import the cloned project to IDE and run it.
            – Hrudayanath
            Nov 10 at 6:08




            @LightCC can you try out jetbrains.com/help/idea/… , just try creating simple hello world program and try to run it, once done you can import the cloned project to IDE and run it.
            – Hrudayanath
            Nov 10 at 6:08












            Once I point Intellij to Java, then I can build, but I have to find the file with the Main function and directly run it by right-clicking and selecting run. After I do that once, it adds a configuration for "Main" and the normal run button comes available. But if I delete all the files and reclone the repo, I'm back to the same situation - why doesn't that configuration for Main save to the repo?
            – LightCC
            Nov 10 at 23:48




            Once I point Intellij to Java, then I can build, but I have to find the file with the Main function and directly run it by right-clicking and selecting run. After I do that once, it adds a configuration for "Main" and the normal run button comes available. But if I delete all the files and reclone the repo, I'm back to the same situation - why doesn't that configuration for Main save to the repo?
            – LightCC
            Nov 10 at 23:48










            up vote
            0
            down vote



            accepted











            1. The first part is ensuring Java is setup, and that Intellij IDEA knows where Java is, per the other answers, comments, and addendums to the question.


            2. The second part is setting up the run/debug configuration, per the "It's working but.." section of the question. This can be created automatically by right-clicking the file that has the main class to be run (usually Main()...), and selecting the "Run Main.main()" option (replacing Main and main() with the file and function which needs to be run)



            3. The final piece is that to get the run/debug configurations to save to the repo, you either need to:




              • Share the workspace.xml file (i.e. make sure this is not in the .gitignore file). However, there is a lot of user-specific stuff in that file, so it should normally be excluded from the repo.

              • Or, edit the configuration and checkmark the "Share" box in the upper right-hand corner (just right of the "Name" field). This will put the configuration into a separate folder inside the .idea folder, which should not be excluded from the repo by .gitignore.




            enter image description here



            enter image description here






            share|improve this answer

























              up vote
              0
              down vote



              accepted











              1. The first part is ensuring Java is setup, and that Intellij IDEA knows where Java is, per the other answers, comments, and addendums to the question.


              2. The second part is setting up the run/debug configuration, per the "It's working but.." section of the question. This can be created automatically by right-clicking the file that has the main class to be run (usually Main()...), and selecting the "Run Main.main()" option (replacing Main and main() with the file and function which needs to be run)



              3. The final piece is that to get the run/debug configurations to save to the repo, you either need to:




                • Share the workspace.xml file (i.e. make sure this is not in the .gitignore file). However, there is a lot of user-specific stuff in that file, so it should normally be excluded from the repo.

                • Or, edit the configuration and checkmark the "Share" box in the upper right-hand corner (just right of the "Name" field). This will put the configuration into a separate folder inside the .idea folder, which should not be excluded from the repo by .gitignore.




              enter image description here



              enter image description here






              share|improve this answer























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted







                1. The first part is ensuring Java is setup, and that Intellij IDEA knows where Java is, per the other answers, comments, and addendums to the question.


                2. The second part is setting up the run/debug configuration, per the "It's working but.." section of the question. This can be created automatically by right-clicking the file that has the main class to be run (usually Main()...), and selecting the "Run Main.main()" option (replacing Main and main() with the file and function which needs to be run)



                3. The final piece is that to get the run/debug configurations to save to the repo, you either need to:




                  • Share the workspace.xml file (i.e. make sure this is not in the .gitignore file). However, there is a lot of user-specific stuff in that file, so it should normally be excluded from the repo.

                  • Or, edit the configuration and checkmark the "Share" box in the upper right-hand corner (just right of the "Name" field). This will put the configuration into a separate folder inside the .idea folder, which should not be excluded from the repo by .gitignore.




                enter image description here



                enter image description here






                share|improve this answer













                1. The first part is ensuring Java is setup, and that Intellij IDEA knows where Java is, per the other answers, comments, and addendums to the question.


                2. The second part is setting up the run/debug configuration, per the "It's working but.." section of the question. This can be created automatically by right-clicking the file that has the main class to be run (usually Main()...), and selecting the "Run Main.main()" option (replacing Main and main() with the file and function which needs to be run)



                3. The final piece is that to get the run/debug configurations to save to the repo, you either need to:




                  • Share the workspace.xml file (i.e. make sure this is not in the .gitignore file). However, there is a lot of user-specific stuff in that file, so it should normally be excluded from the repo.

                  • Or, edit the configuration and checkmark the "Share" box in the upper right-hand corner (just right of the "Name" field). This will put the configuration into a separate folder inside the .idea folder, which should not be excluded from the repo by .gitignore.




                enter image description here



                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 12 at 5:02









                LightCC

                1,158725




                1,158725






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53236310%2fhow-to-save-java-project-from-intellij-idea-to-git-repo-so-it-will-build-on-anot%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

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python