3

I used launch4j, Innosetup to create a installer of my java program. I have 6 classes. I added all the classes and required jar in launch4j. The exe get created through launch4j. I created an installer using innosetup. When I try to run the installer, the following error occurs...

Java Virtual Machine Launcher

Could not find the main class :JavaSamp the program will exit.

Any suggestion pls

build.xml:

<project basedir="." default="build" name="JavaSamp">
    <target name="build">
        <mkdir dir="classes" />     
        <mkdir dir="install/lib" />
        <jar destfile="install/lib/JavaSamp.jar" basedir="classes" />       
        <copy todir="install/jre6">
            <fileset dir="C:\Program Files\Java\jre6">
                <include name="*" />
                <include name="bin/**" />
                <include name="lib/**" />
                <exclude name="lib/charsets.jar" />
                <exclude name="lib/ext/sunjce_provider.jar" />
                <exclude name="bin/rmid.exe" />
                <exclude name="bin/rmiregistry.exe" />
                <exclude name="bin/tnameserv.exe" />
                <exclude name="bin/keytool.exe" />
                <exclude name="bin/kinit.exe" />
                <exclude name="bin/klist.exe" />  
                <exclude name="bin/ktab.exe" />
                <exclude name="bin/policytool.exe" />
                <exclude name="bin/orbd.exe" />
                <exclude name="bin/servertool.exe" />
                <exclude name="bin/java.exe" />
                <exclude name="bin/javaws.exe" />
                <exclude name="bin/javacpl.exe" />
                <exclude name="bin/jucheck.exe" />
                <exclude name="bin/jusched.exe" />
                <exclude name="bin/wsdetect.dll" />
                <exclude name="bin/npjava*.dll" />
                <exclude name="bin/npoji610.dll" />
                <exclude name="bin/regutils.dll" />
                <exclude name="bin/axbridge.dll" />
                <exclude name="bin/deploy.dll" />
                <exclude name="bin/jpicom.dll" />
                <exclude name="bin/javacpl.cpl" />
                <exclude name="bin/jpiexp.dll" />
                <exclude name="bin/jpinscp.dll" />
                <exclude name="bin/jpioji.dll" />
                <exclude name="bin/jpishare.dll" />
                <exclude name="lib/deploy.jar" />
                <exclude name="lib/plugin.jar" />
                <exclude name="lib/deploy/messages*.properties" />
                <exclude name="lib/deploy/splash.jpg" />
            </fileset>
        </copy>
        <exec executable="C:\Program Files\Launch4j\launch4jc.exe">
            <arg value="${basedir}\installerLaunch4j.xml" />
        </exec>
        <exec executable="C:\Program Files\Inno Setup 5\ISCC.exe">
            <arg value="${basedir}\InnoSetup.iss" />
        </exec>         
        <echo message="JavaSampSetup.exe ready" />
    </target>
</project>

installerLaunch4j.xml:

<launch4jConfig>
  <dontWrapJar>true</dontWrapJar>
  <headerType>gui</headerType>
  <jar></jar>
  <outfile>install\JavaSamp.exe</outfile>
  <errTitle></errTitle>
  <cmdLine></cmdLine>
  <chdir>.</chdir>
  <priority>normal</priority>
  <downloadUrl>http://java.com/download</downloadUrl>
  <supportUrl></supportUrl>
  <customProcName>true</customProcName>
  <stayAlive>false</stayAlive>
  <manifest></manifest>
  <icon></icon>
  <classPath>
    <mainClass>JavaSamp</mainClass>
    <cp>lib/DataBaseHelper.jar</cp>
    <cp>lib/WriteHelper.jar</cp>
    <cp>lib/FileEncryption.jar</cp>
    <cp>lib/JavaDemo.jar</cp>
    <cp>lib/SendEmail.jar</cp>
    <cp>lib/JavaSamp.jar</cp>
    <cp>lib/JavaSamp$1.jar</cp>
    <cp>lib/JavaSamp$2.jar</cp>
    <cp>lib/JavaSamp$3.jar</cp>
    <cp>lib/JavaSamp$4.jar</cp>
    <cp>lib/JavaSamp$Myemail.jar</cp>
    <cp>lib/JavaSamp$Myemail$1.jar</cp>
    <cp>lib/JavaSamp$Myemail$2.jar</cp>
    <cp>lib/JavaSamp$Myemail$3.jar</cp>
    <cp>lib/JavaSamp$Myemail$4.jar</cp>
    <cp>lib/JavaSamp$OpenL.jar</cp>
    <cp>lib/JavaSamp$Samp.jar</cp>
    <cp>lib/JavaSamp$Samp$1.jar</cp>
    <cp>lib/JavaSamp$Samp1.jar</cp>
    <cp>lib/JavaSamp$Samp1$1.jar</cp>
    <cp>lib/jxl-2.6.jar</cp>
    <cp>lib/ant.jar</cp>
    <cp>lib/sys_data.db</cp>
    <cp>lib/dnsns.jar</cp>
    <cp>lib/dsn.jar</cp>
    <cp>lib/encrypt.data</cp>
    <cp>lib/imap.jar</cp>
    <cp>lib/javaws.jar</cp>
    <cp>lib/jce.jar</cp>
    <cp>lib/jsse.jar</cp>
    <cp>lib/localedata.jar</cp>
    <cp>lib/mail.jar</cp>
    <cp>lib/mailapi.jar</cp>
    <cp>lib/pop3.jar</cp>
    <cp>lib/private.der</cp>
    <cp>lib/public.der</cp>
    <cp>lib/rt.jar</cp>
    <cp>lib/secure.data</cp>
    <cp>lib/SendEmail.jar</cp>
    <cp>lib/smtp.jar</cp>
    <cp>lib/sqlitejdbc-v056.jar</cp>
    <cp>lib/sunjce_provider.jar</cp>
    <cp>lib/sunmscapi.jar</cp>
    <cp>lib/sunpkcs11.jar</cp>
    <cp>lib/tools.jar</cp>
    <cp>lib/unencryptedFile</cp>
    <cp>sys_data.db</cp>
    <cp>lib/install_details.xls</cp>
    <cp>install_details.xls</cp>
  </classPath>
  <jre>
    <path>jre6</path>
    <minVersion></minVersion>
    <maxVersion></maxVersion>
    <jdkPreference>preferJre</jdkPreference>
  </jre>
  <versionInfo>
    <fileVersion>1.0.0.0</fileVersion>
    <txtFileVersion>1.0</txtFileVersion>
    <fileDescription>JavaSamp</fileDescription>
    <copyright>CopyRight (c) 2011 FSP</copyright>
    <productVersion>1.0.0.0</productVersion>
    <txtProductVersion>1.0</txtProductVersion>
    <productName>JavaSamp</productName>
    <companyName>FSP</companyName>
    <internalName>JavaSamp final</internalName>
    <originalFilename>JavaSamp.exe</originalFilename>
  </versionInfo>
</launch4jConfig>
Community
  • 1
  • 1
Manikandan
  • 1,479
  • 6
  • 48
  • 89
  • Hard to answer without details about the classes you are adding. One possible cause is a lowercase/uppercase mismatch, but that's only a guess. – Wivani Jun 28 '11 at 14:27
  • 1
    Please post the command line you are using to run it. Try removing any colon (`:`) you have attached to the class name too. The error message says `:JavaSamp` which looks suspicious. – Mike Samuel Jun 28 '11 at 15:30
  • I am running through command line.. I used launch4j and innosetup in ant build and run that ant build. exe created and the setup also created through innosetup. while running the setup at the end this error occurs.... – Manikandan Jun 28 '11 at 15:36
  • 1
    The code snippet you have isn't really important here. What is important is your build process. Include your build.xml (if you're using ant) as well as your launch4j configuration. There is some problem with how you are compiling/packaging/deploying/running your application. – wolfcastle Jun 28 '11 at 16:35

2 Answers2

0

As an experiment, try creating a JAR file for your application, and try running it as follows:

java -cp your.jar JavaSamp

If that works, then the problem is something to do with the way that you created that installer.


FWIW, you do not need to write java.lang.String. Just String will do fine.


UPDATE

That exception indicates that the class file is mangled ... or more likely that it is not a Java class file at all.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • I run that command. Got exception, **Exception in thread "main" java.lang.ClassFormatError: Incompatible magic value 1347093252 in class file JavaSamp** – Manikandan Jun 28 '11 at 15:55
  • That particular magic value indicates that JavaSamp.class is actually a jar (or other zip) file. – kenj0418 Mar 01 '12 at 18:38
0

I see you have had "java.lang.ClassFormatError: Incompatible magic value" exception.

I can't give you direct answer/solution but I can add that I have had these issues before and they were related to java version conflicts. I was using java 6 and 1.4.2 and sometimes would see this error.

What version of java are you using?

james4563
  • 169
  • 1
  • 13