6 Replies Latest reply: Jul 23, 2010 5:31 PM by 843804 RSS

    "Cannot find the main Class. Program will exit."

    843804
      Hi, I created a program, and I am trying to distribute it to other people in my office. I tried using both NetBeans 6.8/6.9 and eclipse. I exported to a single jar file. When I run this single .jar file, it runs perfectly. I sent it to one of my coworkers, and the message "Cannot find the main Class. Program will exit." popped up. I then had IT update his Java to 6.20 and it worked. The problem is that this program must be distributed to over 100 people, and I cannot have them each update their Java individually, nor will IT update everyone's on their own. They all have Java 4.XX I believe. Is there any way around this error that only happens on older versions of java? I have checked my manifest file and what not, as I said it runs on computers with Java 6.
        • 1. Re: "Cannot find the main Class. Program will exit."
          793415
          roffir wrote:
          ..They all have Java 4.XX I believe. ..
          Do you mean Java 1.4? It is best to be sure, so point some of the target machines at this page(1) to check.

          1) [http://pscode.org/prop/?prop=java.version,java.vm.version]
          ..Is there any way around this error that only happens on older versions of java?..
          a) Ensure the code does not use functionality introduced in later versions, e.g. assertions, generics, for-each loops.. Using the [cross-compilation options of javac|http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html#crosscomp-options] will warn of those.
          b) Ensure the code does not use any classes, attributes or methods that were not available in the earlier version, then use the cross-compilation options of javac when compiling. Actually the second will alert of the first, so long as the -bootclasspath parameter is used with an appropriate rt.jar.
          • 2. Re: "Cannot find the main Class. Program will exit."
            843804
            AndrewThompson64 wrote:

            Do you mean Java 1.4? It is best to be sure, so point some of the target machines at this page(1) to check.
            Yes, Sorry I meant 1.4.XX, I think they have 1.4.2_19.
            >
            >
            a) Ensure the code does not use functionality introduced in later versions, e.g. assertions, generics, for-each loops.. Using the [cross-compilation options of javac|http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html#crosscomp-options] will warn of those.
            b) Ensure the code does not use any classes, attributes or methods that were not available in the earlier version, then use the cross-compilation options of javac when compiling. Actually the second will alert of the first, so long as the -bootclasspath parameter is used with an appropriate rt.jar.
            I believe that everything is ok, unless some of the swing functions cannot be used in 1.4. Besides the swing functions (which I am not sure about) everything should be able to be used in 1.4
            Thank You
            • 3. Re: "Cannot find the main Class. Program will exit."
              EJP
              "Cannot find the main Class. Program will exit."
              Is that your message or a java message?
              • 4. Re: "Cannot find the main Class. Program will exit."
                843804
                ejp wrote:
                Is that your message or a java message? It is a jvml message.
                A dialog box pops up with the title "Java Virtual Machine Launcher", and the message says "Could not find the main class. Program will exit.", and then just an ok button to close it.
                • 5. Re: "Cannot find the main Class. Program will exit."
                  843804
                  I run into this same error when the user has a lower version JRE installed. Say you programmed the application to use JRE 1.6 or 1.5 libraries and they only have JRE 1.4 installed...
                  • 6. Re: "Cannot find the main Class. Program will exit."
                    843804
                    in netbeans, you can see what JRE/JDK you are developing for by right-clicking the project, going to properties. The default screen for properties should have the option at the top for "Java Platform:"