Executable jar

Hello,

I am just trying Studio Creator with a simple project GridBagLayoutDemo.java.

I can easily build an executable jar file with this using command line but when I build it as a project in Studio Creator it runs OK from the IDE but if I try to double-click the jar file I get the message, 'Failed to load Main-Class attribute'.

I have seen other posts on the forum about editing the manifest.mf file but there is no manifest.mf file in the project.

I see a warning when creating a new project that a J2SE library does not contain a main class.

Is there a way to have Studio Creator generate a manifest.mf file with Main-Class attributes?

[679 byte] By [longbreaka] at [2007-11-27 1:11:00]
# 1

I take it you have created a Java Class Library" project . This creates a new J2SE library in a standard IDE project. A J2SE library does not contain a main class. Standard projects use an IDE-generated Ant build script to build, run, and debug your project.

I suggest you use NetBeans to create a "Java Application" project. So you can create the Jar in NetBeans then if you want to use it in Java Studio Creator, you can add it to the Creator project.

Also, now most of the Creator features are available in Netbeans as Netbeans Visual Webpack. See for more info:

http://www.netbeans.org/products/visualweb/

Rradhikaa at 2007-7-11 23:46:20 > top of Java-index,Development Tools,Java Tools...
# 2
More info: http://blogs.sun.com/radhika/category/Creator
Rradhikaa at 2007-7-11 23:46:20 > top of Java-index,Development Tools,Java Tools...
# 3

Thanks for your kind assistance Rradhika. Your link fixed it.

However for a dummy like me it would be better to specify:

Find the following lines in build-impl.xml file (This file is located in the nbproject directory):

<target name="-post-jar">

<!-- Empty placeholder for easier customization. -->

<!-- You can override this target in the ../build.xml file. -->

</target>

Replace with following lines-

<target name="-post-jar">

<j2seproject1:jar>

<j2seproject1:manifest>

<j2seproject1:attribute name="Main-Class" value="${main.class}"/>

</j2seproject1:manifest>

</j2seproject1:jar>

<!-- Empty placeholder for easier customization. -->

<!-- You can override this target in the ../build.xml file. -->

</target>

My first feeble attempt failed as I literally added the code at the end of the build-impl.xml file and got a corrupt file error.

longbreaka at 2007-7-11 23:46:20 > top of Java-index,Development Tools,Java Tools...
# 4
Sorry about that. I have edited the blog entry with your suggestion
Rradhikaa at 2007-7-11 23:46:20 > top of Java-index,Development Tools,Java Tools...