Results 1 to 2 of 2
  1. #1
    Syranno is offline Member
    Join Date
    Jul 2008
    Posts
    1
    Rep Power
    0

    Default Could not find main class - JDK 1.6

    Hello community,

    First, sorry for my bad english :(

    i wrote a programm for work. If i compile this programm with JDK 1.5 the jar file works. But in this case a JWindow which i use in my programm does'nt shown. If i compile my programm with JDK 1.6 and launch the programm via eclipse the JWindow works. But if i compile it to a jar file, the error occures:

    Could not find main class. Programm will exit.
    It is impossible that the manifest file is wrong, because i trayed to create the jar with JDK 1.5 and it works, but the JWindow i used doesn'nt work.

    Have anybody an idea what i can do, to come to a solution?

    Here my Manifest.mf:

    Java Code:
    Manifest-Version: 1.0
    Main-Class: main.Main
    Class-Path: . Lib/dgl.jar Lib/swingl.jar Lib/ojdbc.jar Lib/swingx.jar Lib/log4j.jar Lib/poi.jar
    and here is my ant script to bild the jar:

    Java Code:
    <project name="CAT-DB" default="dist">
      <property name="MyApp" value="CAT-DB" />
      <path id="compile.classpath">
        <fileset dir="lib" />
        <pathelement path="bin" />
      </path>
      <target name="compile">
        <javac srcdir="src" destdir="bin">
          <classpath refid="compile.classpath" />
        </javac>
      </target>
      <!-- Create binary distribution -->
      <target name="dist" depends="compile">
        <delete file="${MyApp}.jar"/>
        <delete file="dist/${MyApp}.zip"/>
        <mkdir dir="dist" />
        <jar jarfile="${MyApp}.jar"
             basedir="bin"
             manifest="manifest.mf" />
        <zip destfile="dist/${MyApp}.zip">
          <fileset dir="." includes="lib/*" />
          <fileset dir="." includes="${MyApp}.jar" />
        </zip>
      </target>
    </project>
    I have tryed to create the jar with eclipse, but the same error occurce.

    If i try to start the programm via command it works and the JWindow works too.

    javaw.exe -Dfile.encoding=Cp1252 -classpath "W:\S_Ausbildung\02_Fachinformatiker\FI2006\Webers \Java Workspace\CAT-DB\bin;W:\S_Ausbildung\02_Fachinformatiker\FI2006\ Webers\Java Workspace\CAT-DB\Lib\swingx.jar;W:\S_Ausbildung\02_Fachinformati ker\FI2006\Webers\Java Workspace\CAT-DB\Lib\dgl.jar;W:\S_Ausbildung\02_Fachinformatiker \FI2006\Webers\Java Workspace\CAT-DB\Lib\log4j.jar;W:\S_Ausbildung\02_Fachinformatik er\FI2006\Webers\Java Workspace\CAT-DB\Lib\ojdbc.jar;W:\S_Ausbildung\02_Fachinformatik er\FI2006\Webers\Java Workspace\CAT-DB\Lib\poi.jar;W:\S_Ausbildung\02_Fachinformatiker \FI2006\Webers\Java Workspace\CAT-DB\Lib\swingl.jar" main.Main
    Thanks for your time and your help.

    Regards Syranno
    Last edited by Syranno; 07-25-2008 at 03:47 PM.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,581
    Rep Power
    25

    Default

    Is the version of the javaw command 1.6? version 1.5 will not be able to execute code generated by a 1.6 javac.

    You say that the program works if you use the javaw command, put the jar files on the classpath and reference the starting class.
    That would mean that the jar file contains all the class files it needs and the classpath points to what else it needs

    The problem must be in the manifest.
    What error message do you get if you open a console window and enter: java -jar <jarname>.jar?

    I don't know about JWindow or eclipse, so if the problem is with either of them I can't help.

Similar Threads

  1. Replies: 2
    Last Post: 09-22-2011, 09:48 PM
  2. Could not find the main class, program will exit.
    By aryubi in forum New To Java
    Replies: 39
    Last Post: 02-19-2010, 10:02 AM
  3. JVM Could not find main class
    By banduskank in forum Advanced Java
    Replies: 2
    Last Post: 06-24-2008, 08:05 AM
  4. Replies: 0
    Last Post: 05-13-2008, 06:16 AM
  5. problems to find the main method
    By christina in forum Eclipse
    Replies: 2
    Last Post: 08-06-2007, 07:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •