Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Could not find main class [modified]

Could not find main class [modified]

Scheduled Pinned Locked Moved Java
helpcsharpjavasharepointvisual-studio
20 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R RossouwDB

    Gerben Jongerius wrote:

    java -cp myjar.jar;mylib1.jar;mylib2.jar com.classpackage.MyClass

    Unfortunately this did not work. Here is my directory structure: -dist --OmniIDE.jar --lib ---AbsoluteLayout ---appframework-1.0.3.jar ---beansbinding-1.2.1.jar ---swing-layout-1.0.4.jar ---swing-worker-1.1.jar So I CMDd the following:

    java -cp OmniIDE.jar;lib\AbsoluteLayout.jar;lib\appframework-1.0.3.jar;lib\beansbinding-1.2.1.jar;lib\swing-layout-1.0.4.jar;lib\swing-worker-1.1.jar com.omniide.OmniIDEApp

    And the exception (all continuous):

    Exception in thread "main" java.lang.NoClassDefFoundError: com/omniide/OmniIDEApp

    TorstenH. wrote:

    Netbeans should have some "Extract Project" option.

    Unfortunately, no. There are two extract options: -Extract Interface -Extract Superclass Converting from NetBeans to Eclipse would not be an option though... Thanks, Rossouw

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #5

    Where is the class file com/omniide/OmniIDEApp within the items listed in your classpath, and are you sure the spelling is correct?

    The best things in life are not things.

    R 1 Reply Last reply
    0
    • L Lost User

      Where is the class file com/omniide/OmniIDEApp within the items listed in your classpath, and are you sure the spelling is correct?

      The best things in life are not things.

      R Offline
      R Offline
      RossouwDB
      wrote on last edited by
      #6

      I'm not sure I am following... (Java isn't my strongpoint.) I don't set any environment variables myself, and I don't set any classpath myself either. I figured that the jar file (with the manifest and build file), would handle that for me.

      L 1 Reply Last reply
      0
      • R RossouwDB

        I'm not sure I am following... (Java isn't my strongpoint.) I don't set any environment variables myself, and I don't set any classpath myself either. I figured that the jar file (with the manifest and build file), would handle that for me.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #7

        RossouwDB wrote:

        I don't set any classpath myself

        The -cp option followed by a list of .jar files is your classpath. You need to check that the class you are trying to invoke actually exists within one of your .jar files and is under the specified path (i.e. package and class).

        The best things in life are not things.

        R 1 Reply Last reply
        0
        • L Lost User

          RossouwDB wrote:

          I don't set any classpath myself

          The -cp option followed by a list of .jar files is your classpath. You need to check that the class you are trying to invoke actually exists within one of your .jar files and is under the specified path (i.e. package and class).

          The best things in life are not things.

          R Offline
          R Offline
          RossouwDB
          wrote on last edited by
          #8

          Richard MacCutchan wrote:

          -cp option followed by a list of .jar files is your classpath

          crud, I knew but forgot that! Now I follow :-O The omniide is my "main" package, and the omniIDEApp is the entrypoint of my application. Everything is spelled correctly since I have even copied it as is from my Manifest file, but to no avail. Here is the actual code for my entrypoint class:

          /*
          * OmniIDEApp.java
          */

          package omniide;

          import org.jdesktop.application.Application;
          import org.jdesktop.application.SingleFrameApplication;

          /**
          * The main class of the application.
          */
          public class OmniIDEApp extends SingleFrameApplication {

          /\*\*
           \* At startup create and show the main frame of the application.
           \*/
          @Override protected void startup() {
              show(new OmniIDEView(this));
          }
          
          /\*\*
           \* This method is to initialize the specified window by injecting resources.
           \* Windows shown in our application come fully initialized from the GUI
           \* builder, so this additional configuration is not needed.
           \*/
          @Override protected void configureWindow(java.awt.Window root) {
          }
          
          /\*\*
           \* A convenient static getter for the application instance.
           \* @return the instance of OmniIDEApp
           \*/
          public static OmniIDEApp getApplication() {
              return Application.getInstance(OmniIDEApp.class);
          }
          
          /\*\*
           \* Main method launching the application.
           \*/
          public static void main(String\[\] args) {
              launch(OmniIDEApp.class, args);
          }
          

          }

          This code is generated by NetBeans when the project is created. I am stumped as to the cause of this error! :wtf:

          L 1 Reply Last reply
          0
          • R RossouwDB

            Richard MacCutchan wrote:

            -cp option followed by a list of .jar files is your classpath

            crud, I knew but forgot that! Now I follow :-O The omniide is my "main" package, and the omniIDEApp is the entrypoint of my application. Everything is spelled correctly since I have even copied it as is from my Manifest file, but to no avail. Here is the actual code for my entrypoint class:

            /*
            * OmniIDEApp.java
            */

            package omniide;

            import org.jdesktop.application.Application;
            import org.jdesktop.application.SingleFrameApplication;

            /**
            * The main class of the application.
            */
            public class OmniIDEApp extends SingleFrameApplication {

            /\*\*
             \* At startup create and show the main frame of the application.
             \*/
            @Override protected void startup() {
                show(new OmniIDEView(this));
            }
            
            /\*\*
             \* This method is to initialize the specified window by injecting resources.
             \* Windows shown in our application come fully initialized from the GUI
             \* builder, so this additional configuration is not needed.
             \*/
            @Override protected void configureWindow(java.awt.Window root) {
            }
            
            /\*\*
             \* A convenient static getter for the application instance.
             \* @return the instance of OmniIDEApp
             \*/
            public static OmniIDEApp getApplication() {
                return Application.getInstance(OmniIDEApp.class);
            }
            
            /\*\*
             \* Main method launching the application.
             \*/
            public static void main(String\[\] args) {
                launch(OmniIDEApp.class, args);
            }
            

            }

            This code is generated by NetBeans when the project is created. I am stumped as to the cause of this error! :wtf:

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #9

            Are you sure about the com. prefix in your class name:

            java -cp OmniIDE.jar;lib\AbsoluteLayout.jar;lib\appframework-1.0.3.jar;lib\beansbinding-1.2.1.jar;lib\swing-layout-1.0.4.jar;lib\swing-worker-1.1.jar com.omniide.OmniIDEApp

            [edit]You can check this by running the command jar -tvf against the jar file that contains (or should contain) your main class.[/edit] [edit2]Or you could execute the .jar file directly by

            java -cp lib\AbsoluteLayout.jar;lib\appframework-1.0.3.jar;lib\beansbinding-1.2.1.jar;lib\swing-layout-1.0.4.jar;lib\swing-worker-1.1.jar -jar OmniIDE.jar

            assuming your main class is in the OmniIDE.jar file. [/edit2]

            The best things in life are not things.

            R 2 Replies Last reply
            0
            • L Lost User

              Are you sure about the com. prefix in your class name:

              java -cp OmniIDE.jar;lib\AbsoluteLayout.jar;lib\appframework-1.0.3.jar;lib\beansbinding-1.2.1.jar;lib\swing-layout-1.0.4.jar;lib\swing-worker-1.1.jar com.omniide.OmniIDEApp

              [edit]You can check this by running the command jar -tvf against the jar file that contains (or should contain) your main class.[/edit] [edit2]Or you could execute the .jar file directly by

              java -cp lib\AbsoluteLayout.jar;lib\appframework-1.0.3.jar;lib\beansbinding-1.2.1.jar;lib\swing-layout-1.0.4.jar;lib\swing-worker-1.1.jar -jar OmniIDE.jar

              assuming your main class is in the OmniIDE.jar file. [/edit2]

              The best things in life are not things.

              R Offline
              R Offline
              RossouwDB
              wrote on last edited by
              #10

              I have tried omitting it, but still doesn't work.

              L 1 Reply Last reply
              0
              • R RossouwDB

                I have tried omitting it, but still doesn't work.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #11

                See my edits to my previous message.

                The best things in life are not things.

                1 Reply Last reply
                0
                • L Lost User

                  Are you sure about the com. prefix in your class name:

                  java -cp OmniIDE.jar;lib\AbsoluteLayout.jar;lib\appframework-1.0.3.jar;lib\beansbinding-1.2.1.jar;lib\swing-layout-1.0.4.jar;lib\swing-worker-1.1.jar com.omniide.OmniIDEApp

                  [edit]You can check this by running the command jar -tvf against the jar file that contains (or should contain) your main class.[/edit] [edit2]Or you could execute the .jar file directly by

                  java -cp lib\AbsoluteLayout.jar;lib\appframework-1.0.3.jar;lib\beansbinding-1.2.1.jar;lib\swing-layout-1.0.4.jar;lib\swing-worker-1.1.jar -jar OmniIDE.jar

                  assuming your main class is in the OmniIDE.jar file. [/edit2]

                  The best things in life are not things.

                  R Offline
                  R Offline
                  RossouwDB
                  wrote on last edited by
                  #12

                  Richard MacCutchan wrote:

                  running the command jar -tvf against the jar file that contains (or should contain) your main class

                  Confirms that com. is not needed, and that my main class is contained within the OmniIDE.jar file.

                  Richard MacCutchan wrote:

                  Or you could execute the .jar file directly

                  Does not work.

                  L 1 Reply Last reply
                  0
                  • R RossouwDB

                    Richard MacCutchan wrote:

                    running the command jar -tvf against the jar file that contains (or should contain) your main class

                    Confirms that com. is not needed, and that my main class is contained within the OmniIDE.jar file.

                    Richard MacCutchan wrote:

                    Or you could execute the .jar file directly

                    Does not work.

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #13

                    RossouwDB wrote:

                    Does not work.

                    Really not a helpful definition of a problem! What's the output of the jar -tvf command? Also what happens when you try with the -jar option? Please show exact commands and exact output in all cases. PS: I do not use NetBeans but Eclipse, and I know there are some bits of framework stuff that NetBeans adds to your package so it may well be that you cannot run the final package outside of the NetBeans environment. However, why that would be so is anyone's guess.

                    The best things in life are not things.

                    R T 2 Replies Last reply
                    0
                    • L Lost User

                      RossouwDB wrote:

                      Does not work.

                      Really not a helpful definition of a problem! What's the output of the jar -tvf command? Also what happens when you try with the -jar option? Please show exact commands and exact output in all cases. PS: I do not use NetBeans but Eclipse, and I know there are some bits of framework stuff that NetBeans adds to your package so it may well be that you cannot run the final package outside of the NetBeans environment. However, why that would be so is anyone's guess.

                      The best things in life are not things.

                      R Offline
                      R Offline
                      RossouwDB
                      wrote on last edited by
                      #14

                      I don't know how and why, but now everything is working!! I was typing away, and doing a clean + build like I normally do,and when I tried to run it again, it bombarded me with error messages indicating that a lot of my packages could not be found! Stumped, I cleaned and built it a couple of times, but failed miserably when I want to run it (really odd, since it was running successfully a couple of seconds ago.) So, I located the "broken" package, and renamed it to the package NetBeans expected. Cleaned and built it, ran it - it worked. So i though I might give executing the application a shot, and it worked! It's really odd though, since NetBeans should have complained right from the start, but for some reason, it didn't.:confused: Anyway, thanks for your help.

                      1 Reply Last reply
                      0
                      • L Lost User

                        RossouwDB wrote:

                        Does not work.

                        Really not a helpful definition of a problem! What's the output of the jar -tvf command? Also what happens when you try with the -jar option? Please show exact commands and exact output in all cases. PS: I do not use NetBeans but Eclipse, and I know there are some bits of framework stuff that NetBeans adds to your package so it may well be that you cannot run the final package outside of the NetBeans environment. However, why that would be so is anyone's guess.

                        The best things in life are not things.

                        T Offline
                        T Offline
                        TorstenH
                        wrote on last edited by
                        #15

                        Stop. that. NOW! This is no simple Java homework that's not running. Packaging and Deploying Desktop Java Applications with Netbeans[^] Check that, READ IT and follow the instructions instead of burning money online.

                        regards Torsten I never finish anyth...

                        L R 2 Replies Last reply
                        0
                        • T TorstenH

                          Stop. that. NOW! This is no simple Java homework that's not running. Packaging and Deploying Desktop Java Applications with Netbeans[^] Check that, READ IT and follow the instructions instead of burning money online.

                          regards Torsten I never finish anyth...

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #16

                          Sorry, what?

                          The best things in life are not things.

                          1 Reply Last reply
                          0
                          • T TorstenH

                            Stop. that. NOW! This is no simple Java homework that's not running. Packaging and Deploying Desktop Java Applications with Netbeans[^] Check that, READ IT and follow the instructions instead of burning money online.

                            regards Torsten I never finish anyth...

                            R Offline
                            R Offline
                            RossouwDB
                            wrote on last edited by
                            #17

                            Wait, what???? Dude, you ok? Did I say this is homework?????

                            T 1 Reply Last reply
                            0
                            • R RossouwDB

                              Wait, what???? Dude, you ok? Did I say this is homework?????

                              T Offline
                              T Offline
                              TorstenH
                              wrote on last edited by
                              #18

                              This is no simple Java homework Netbeans should provide a functionality to export your project in a proper way. There is no need to build some strange stuff. That's time waisted.

                              regards Torsten I never finish anyth...

                              R 1 Reply Last reply
                              0
                              • T TorstenH

                                This is no simple Java homework Netbeans should provide a functionality to export your project in a proper way. There is no need to build some strange stuff. That's time waisted.

                                regards Torsten I never finish anyth...

                                R Offline
                                R Offline
                                RossouwDB
                                wrote on last edited by
                                #19

                                TorstenH. wrote:

                                This is no simple Java homework

                                It's NOT HOMEWORK. It's a project I am working on...

                                TorstenH. wrote:

                                Netbeans should provide a functionality to export your project in a proper way.

                                Clearly it's not always working so well, but I would still use NetBeans.

                                TorstenH. wrote:

                                There is no need to build some strange stuff

                                Why not??? What isn't strange in live? Clearly you are.... So am I!

                                TorstenH. wrote:

                                That's time waisted

                                No, actually it's not! I have learned something from this entire experience, so I would not say it's time wasted! **Note:**If you don't want to help people, and you want to attack them for some strange and peculiar reason, rather keep quiet! (Go read the guidelines: Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers!)

                                T 1 Reply Last reply
                                0
                                • R RossouwDB

                                  TorstenH. wrote:

                                  This is no simple Java homework

                                  It's NOT HOMEWORK. It's a project I am working on...

                                  TorstenH. wrote:

                                  Netbeans should provide a functionality to export your project in a proper way.

                                  Clearly it's not always working so well, but I would still use NetBeans.

                                  TorstenH. wrote:

                                  There is no need to build some strange stuff

                                  Why not??? What isn't strange in live? Clearly you are.... So am I!

                                  TorstenH. wrote:

                                  That's time waisted

                                  No, actually it's not! I have learned something from this entire experience, so I would not say it's time wasted! **Note:**If you don't want to help people, and you want to attack them for some strange and peculiar reason, rather keep quiet! (Go read the guidelines: Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers!)

                                  T Offline
                                  T Offline
                                  TorstenH
                                  wrote on last edited by
                                  #20

                                  ..That's what I said - this does not look like a simple homework-project that can be simply launched from the command line. Why would you even want to work on the command line? All you're asking for is to run it outside of your IDE. So I recommend to export the project in the given way and that's it. Netbeans will do what is is supposed to do - build your application. No need to waste hours of time on fuzzy command line arguments. Better get a nice ice cream and watch Netbeans do the build :cool:

                                  regards Torsten I never finish anyth...

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups