ceyezumma -3 Light Poster

Hello all:

Has anyone tried one jar and received an error that the main class will not Load?


I used "ONE JAR" and created the executable and I altered the build file.

response from simon:
Main-Class: com\simontuffs\onejar.Boot One-Jar-Main-Class: musicSystems.src.view.Main

"Main-Class" is the "standard" Java JAR main class launcher, used by "java -jar" to know what to execute. It should point to the com.simontuffs.onejar.Boot class, which then reads the one-jar and launches the class pointed to by "One-Jar-Main-Class" -- your application.

above discribes how the one jar process is working

reads the one-jar and launches the class pointed to by "One-Jar-Main-Class"

This suggest that the build file is not in play. Do I need to do anyThing to
the build file found in the one-jar-sdk-0.97.zip provided?


Below are the command and the build file and errors:


Double clicking the musicSystems.jar that the One Jar produces:

A Java Exception has occurred.

C:\Program Files\Java\jdk1.7.0_01\bin>jar -cvfm C:\Users\Steves\Documents\ceyesu
mma\java_cache\my_projects\netbeans\musicSystems\target_musicSystems\BundlingToo
ls\musicSystems.jar C:\Users\Steves\Documents\ceyesumma\java_cache\my_projects\n
etbeans\musicSystems\target_musicSystems\BundlingTools\META-INF\MANIFEST.MF
added manifest

C:\Program Files\Java\jdk1.7.0_01\bin>jar -tvf C:\Users\Steves\Documents\ceyesum
ma\java_cache\my_projects\netbeans\musicSystems\target_musicSystems\BundlingTool
s\musicSystems.jar
0 Wed Jan 18 08:47:36 CST 2012 META-INF/
304 Wed Jan 18 08:47:36 CST 2012 META-INF/MANIFEST.MF

C:\Program Files\Java\jdk1.7.0_01\bin>java -jar -Xmx256m C:\Users\Steves\Documen
ts\ceyesumma\java_cache\my_projects\netbeans\musicSystems\target_musicSystems\Bu
ndlingTools\musicSystems.jar
Exception in thread "main" java.lang.NullPointerException
at sun.launcher.LauncherHelper.getMainClassFromJar(LauncherHelper.java:3
99)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:463)


C:\Program Files\Java\jdk1.7.0_01\bin>

Result from command :

Exception in thread "main" java.lang.NullPointerException
        at sun.launcher.LauncherHelper.getMainClassFromJar(LauncherHelper.java:3
99)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:463)


C:\Program Files\Java\jdk1.7.0_01\bin>

The altered Build.xml

<project name="one-jar-sdk" default="sdk">

<property name="one-jar.dist.dir" value="${basedir}"/>

<property name="src.main.dir" location="${basedir}/src/main"/>
<property name="src.lib.dir" location="${basedir}/src/lib"/>
<property name="src.install.dir" location="${basedir}/src/install"/>
<property name="lib.dir" location="${basedir}/lib"/>
<property name="build.dir" location="${basedir}/build"/>

<property name="classes.dir" location="${basedir}/classes"/>

<target name="init">
<mkdir dir="${src.main.dir}"/>
<mkdir dir="${src.lib.dir}"/>
<mkdir dir="${lib.dir}"/>
<mkdir dir="${classes.dir}/main"/>
<mkdir dir="${classes.dir}/lib"/>
<mkdir dir="${classes.dir}/src"/>
<mkdir dir="${build.dir}"/>
</target>

<import file="one-jar-ant-task.xml"/>

<target name="musicSystems" depends="init">
<!-- Build lib.jar -->
<javac destdir="${classes.dir}/lib">
<src path="${src.lib.dir}" />
</javac>
<jar destfile="${build.dir}/lib.jar" >
<fileset dir="${classes.dir}/lib"/>
</jar>
<!-- Build classes for main.jar -->
<javac destdir="${classes.dir}/main">
<src path="${src.main.dir}" />
<classpath path="${build.dir}/lib.jar"/>
<classpath>
<fileset dir="${src.lib.dir}"/>
</classpath>
</javac>
<!-- Construct the One-JAR file -->
<one-jar destfile="musicSystems.jar">
<!-- musicSystems.mf:

Main-Class: com.simontuffs.onejar.Boot
One-Jar-Main-Class: com.simontuffs.onejar.musicSystems.Main
-->
<manifest>
<attribute name="One-Jar-Main-Class" value="musicSystems.build.classes.view.Main"/>
</manifest>
<main>
<!-- Construct main.jar from classes and source code -->
<fileset dir="${classes.dir}/main"/>
</main>
<lib>
<fileset file="${build.dir}/lib.jar" />

<!-- This will copy the files in the SDK/lib dir to the lib folder in the jar file-->
<fileset dir="${lib.dir}"/>

</lib>
</one-jar>
<echo>
Now you can run the musicSystems One-JAR example using
$ java -jar musicSystems.jar
</echo>

</target>

<target name="sdk">
<!-- Rebuild this SDK using the One-JAR task. -->
<echo>Building sdk ${one-jar.version}</echo>
<mkdir dir="${classes.dir}/install"/>
<javac destdir="${classes.dir}/install">
<src path="${src.install.dir}" />
</javac>
<delete file="one-jar-sdk-${one-jar.version}.jar"/>
<one-jar destfile="one-jar-sdk-${one-jar.version}.jar">
<!-- one-jar-sdk.mf:

Main-Class: com.simontuffs.onejar.Boot
One-Jar-Main-Class: com.simontuffs.onejar.sdk.Install
One-Jar-Expand:
One-Jar-Expand-Dir: ./one-jar-sdk-${one-jar.version}
One-Jar-Show-Expand: true
-->
<manifest>
<attribute name="One-Jar-Main-Class" value="com.simontuffs.onejar.sdk.Install"/>
<!-- Note: One-Jar-Expand is a list of paths to expand: empty is all -->
<attribute name="One-Jar-Expand" value=""/>
<attribute name="One-Jar-Expand-Dir" value="./one-jar-sdk-${one-jar.version}"/>
<attribute name="One-Jar-Confirm-Expand" value="true"/>
<attribute name="One-Jar-Show-Expand" value="true"/>
</manifest>
<fileset dir=".">
<include name="one-jar-ant-${one-jar.version}.jar"/>
<include name="src/main/**"/>
<include name="src/lib/**"/>
<include name="src/install/**"/>
<include name="build.xml"/>
<include name="README.txt"/>
<include name="one-jar-ant-task*"/>
<include name="*.mf"/>
<include name=".*"/>
<exclude name=".version"/>
</fileset>
<main>
<fileset dir="${classes.dir}/install"/>
</main>
</one-jar>
</target>

<target name="clean">
<delete dir="${classes.dir}"/>
<delete dir="${build.dir}"/>
</target>

</project>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.