Archive for March, 2013
Problem: “Failed to load Main-Class manifest attribute from” error while trying to call main class bundled in a jar file.
Below is the documentation from oracle related to the above error, but i will also show you how do to do this in case if you are using build tool like maven to bundle your jar file.
Setting an Application’s Entry Point
If you have an application bundled in a JAR file, you need some way to indicate which class within the JAR file is your application’s entry point. You provide this information with the
Main-Class header in the manifest, which has the general form:
classname is the name of the class that is your application’s entry point.
Recall that the entry point is a class having a method with signature
public static void main(String args).
After you have set the
Main-Class header in the manifest, you then run the JAR file using the following form of the
java -jar JAR-name
main method of the class specified in the
Main-Class header is executed.
We want to execute the
main method in the class
MyClass in the package
MyPackage when we run the JAR file.
We first create a text file named
Manifest.txt with the following contents:
Warning: The text file must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.
We then create a JAR file named
MyJar.jar by entering the following command:
jar cfm MyJar.jar Manifest.txt MyPackage/*.class
This creates the JAR file with a manifest with the following contents:
Manifest-Version: 1.0 Created-By: 1.7.0_06 (Oracle Corporation) Main-Class: MyPackage.MyClass
When you run the JAR file with the following command, the
main method of
java -jar MyJar.jar
Setting an Entry Point with the JAR Tool
The ‘e’ flag (for ‘entrypoint’), introduced in JDK 6, creates or overrides the manifest’s
Main-Class attribute. It can be used while creating or updating a JAR file. Use it to specify the application entry point without editing or creating the manifest file.
For example, this command creates
app.jar where the
Main-Class attribute value in the manifest is set to
jar cfe app.jar MyApp MyApp.class
You can directly invoke this application by running the following command:
java -jar app.jar
If the entrypoint class name is in a package it may use a ‘.’ (dot) character as the delimiter. For example, if
Main.class is in a package called
foo the entry point can be specified in the following ways:
jar cfe Main.jar foo.Main foo/Main.class Pom.xml
where com.MyPackage.MyClass is the file where the main method exists and classpathPrefix is something where i am expecting some dependant jars to be available. We are interested in mainClass element at this time.
This is how Manifest.MF looks like in META-INF folder inside the jar file
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Main-Class described above will help to load the main method.
Installing Axis2 WAR Distribution
- Download the Axis2 WAR distribution from here: http://axis.apache.org/axis2/java/core/download.cgi
- Deploy it as an exploded directory in your preferred Servlet Container (JBoss, Tomcat, etc).
- axis2.war will be the container to hold multiple aar files, which independently are axis projects themselves
- Go to the axis2.war/WEB-INF/conf/axis2.xml file, and set the hotupdate parameter to true, as follows:
|…<parameter name=”hotupdate”>true</parameter>Check that the Axis2 webapp was successfully deployed by going to this link http://localhost:8080/axis2/ and clicking on ‘Validate’.|
Developing a contract-first web service
- Create a Maven project in eclipse.
- Copy your wsdl and xsd files to src/main/resources. Note: This process assumes you already have an existing WSDL file with external xsd files for the messages definition (Contract-first approach)
- Copy the following to your pom.xml file:
- To generate the java sources from the wsdl, run: mvn clean generate-sources -Pcodegen. This will create the input and output objects of every service, as well as the skeleton files and the services.xml file.
- Copy the files from target/generated-sources/axis2/wsdl2code/src to your src folder.
- Copy the services.xml file from target/generated-sources/axis2/wsdl2code/src to src/main/resources
- Edit the Skeleton class to include the logic you want.
- To generate the .aar file, run: mvn clean compile axis2-aar:aar
- Copy the generated .aar file from target to testws.war/WEB-INF/services
- WSDL URLhttp://host:port/axis2/services/test-services?wsdl
If you would like to convert all your 2003 office documents to 2007, but would like to do all of them in a single shot, here you go.
1. Download Migration Manager from microsoft and install it, which is a free tool
2. Download Office compatibility pack
Once step 1 is done, open the folder where it is installed and look for tools\ofc.ini
Below ofc.ini is complete file and we are interested in one part, the path to provide the source folder under [FoldersToConvert], make sure you have this fldr=C:\localfolder (without a ; before fldr and where localfolder is name of your folder)
; The Converter will attempt to convert all supported files in the specified folders
; (do not include if specifying FileListFolder)
Also you can update DestinationPathTemplate to the path where your converted files need to be available
4. Now open cm.exe and navigate to folder where migration manager is installed and simply run the cmd as ofc.exe
all your files will be converted and available in destination provided above without original files getting affected.