I try to create a jar and add a manifest since my default class cannot be found no matter what I do I checked may threads on SO, still no luck
here is how I create my class and create the jar file
javac.exe -d dist -classpath ./pdfbox-app-2.0.12.jar Pdf.java
jar.exe -cvfm Pdf.jar manifest.txt dist/com/company/*.class
jar.exe tf Pdf.jar
java.exe -jar Pdf.jar
the jar command gives :
added manifest
adding: dist/com/company/Pdf.class(in = 1150) (out= 658)(deflated 42%)
here is what is set in the manifest.txt
Manifest-Version: 1.0
Created-By: My Name
Main-Class: com.company.Pdf
as I checked the manifest in the file, it is not update with my lines
here is the java code if needed :
package com.company;
import java.io.File;
import java.io.IOException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;
public class Pdf {
public static void main(String[] args) {
if(args.length<2)
{
System.out.println("Error ! need 2 parameters");
}
try
{
//Load the document
PDDocument pDDocument = PDDocument.load(new File(args[0]));
PDAcroForm pDAcroForm = pDDocument.getDocumentCatalog().getAcroForm();
//Fill the document
//Flatten the document
pDAcroForm.flatten();
//Save the document
pDDocument.save(args[1]);
pDDocument.close();
}
catch(InvalidPasswordException e)
{
}
catch(IOException e)
{
}
}
}
what do I do wrong ?
thanks
[ANSWER]
here is how I do it
del Pdf.jar
javac -d build -classpath lib/pdfbox-app-2.0.12.jar Pdf.java
jar -cfM Pdf.jar -C build com
jar umf META-INF/MANIFEST.MF Pdf.jar
jar tf Pdf.jar
here is the test
java -jar Pdf.jar
the manifest I use
Manifest-Version: 1.0
Created-By: ......
Main-Class: com.company.Pdf
Class-Path: lib/pdfbox-app-2.0.12.jar