You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Lorena Leishman <lo...@yahoo.com.INVALID> on 2015/01/14 18:25:35 UTC
Could not find or load main class
My environmental CLASSPATH is set to .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar
I can't run anythhing anymore. I can compile this FillTestField file but I can't run it. Or anything else. Not even Welcome.Class. I keep getting "Could not find or load main class FillTestField" I have tried:Changing the classpath to .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar;C:\Users\Dad\Downloads .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar;.;C:\Users\Dad\Downloads
.;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar;C:\Users\Dad\Downloads\FillTestField.class
or from the prompt line: java -cp . FillTestField (from same folder where file is)java -cp C:\Users\Dad\Downloads\FillTestField (With this one I got a whole list of java help commands, etc)
Any ideas? Thanks for all your help.
//FillTestFieldpackage org.apache.pdfbox.examples.acroforms;import java.io.File;
import java.io.IOException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.exceptions.*;
import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;import org.apache.pdfbox.pdmodel.interactive.form.PDField;
import org.apache.pdfbox.pdmodel.interactive.form.PDTextbox;
public class FillTestField {
public static void main(String[] args) throws IOException { String formTemplate = "Users/Dad/Desktop/TCRM/game plan 12-16.pdf"; String filledForm = "Users/Dad/JavaTest/game plan 12-16.pdf"; // load the document PDDocument pdfDocument = PDDocument .load(new File(formTemplate),null);
// get the document catalog PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm(); // as there might not be an AcroForm entry a null check is necessary if (acroForm != null) { // Retrieve an individual field and set it's value. PDTextbox field = (PDTextbox) acroForm.getField( "Goal" ); field.setValue("Text Entry"); // If a field is nested within the form tree a fully qualified name // might be provided to access the field. field = (PDTextbox) acroForm.getField( "fieldsContainer.nestedSampleField" ); field.setValue("Text Entry"); }
// Save and close the filled out form.
//pdfDocument.save(filledForm); pdfDocument.close();
}
}
Re: Could not find or load main class
Posted by Tilman Hausherr <TH...@t-online.de>.
Hi Lorena,
The best is that you install an IDE. There are three major ones:
Netbeans, Eclipse and IntelliJ. Eclipse is the most popular. I recommend
Netbeans.
Tilman
Am 14.01.2015 um 18:25 schrieb Lorena Leishman:
> My environmental CLASSPATH is set to .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar
> I can't run anythhing anymore. I can compile this FillTestField file but I can't run it. Or anything else. Not even Welcome.Class. I keep getting "Could not find or load main class FillTestField" I have tried:Changing the classpath to .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar;C:\Users\Dad\Downloads .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar;.;C:\Users\Dad\Downloads
> .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar;C:\Users\Dad\Downloads\FillTestField.class
> or from the prompt line: java -cp . FillTestField (from same folder where file is)java -cp C:\Users\Dad\Downloads\FillTestField (With this one I got a whole list of java help commands, etc)
> Any ideas? Thanks for all your help.
> //FillTestFieldpackage org.apache.pdfbox.examples.acroforms;import java.io.File;
> import java.io.IOException;
> import org.apache.pdfbox.pdmodel.PDDocument;
> import org.apache.pdfbox.exceptions.*;
> import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;import org.apache.pdfbox.pdmodel.interactive.form.PDField;
> import org.apache.pdfbox.pdmodel.interactive.form.PDTextbox;
>
> public class FillTestField {
> public static void main(String[] args) throws IOException { String formTemplate = "Users/Dad/Desktop/TCRM/game plan 12-16.pdf"; String filledForm = "Users/Dad/JavaTest/game plan 12-16.pdf"; // load the document PDDocument pdfDocument = PDDocument .load(new File(formTemplate),null);
> // get the document catalog PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm(); // as there might not be an AcroForm entry a null check is necessary if (acroForm != null) { // Retrieve an individual field and set it's value. PDTextbox field = (PDTextbox) acroForm.getField( "Goal" ); field.setValue("Text Entry"); // If a field is nested within the form tree a fully qualified name // might be provided to access the field. field = (PDTextbox) acroForm.getField( "fieldsContainer.nestedSampleField" ); field.setValue("Text Entry"); }
> // Save and close the filled out form.
> //pdfDocument.save(filledForm); pdfDocument.close();
> }
> }
>
Re: Could not find or load main class
Posted by John Hewson <jo...@jahewson.com>.
Please excuse my previous typo: ”provably" —> “probably"
-- John
> On 14 Jan 2015, at 09:42, John Hewson <jo...@jahewson.com> wrote:
>
> Hi Lorena,
>
> You provably need to read an introductory book on Java. These sorts of questions
> aren’t really suitable for the PDFBox mailing list.
>
> Or, if you’re in a hurry, try Googling the error message:
> https://www.google.com/#q=Could+not+find+or+load+main+class <https://www.google.com/#q=Could+not+find+or+load+main+class>
>
> Thanks,
>
> -- John
>
>> On 14 Jan 2015, at 09:25, Lorena Leishman <lorenaleishman@yahoo.com.INVALID <ma...@yahoo.com.INVALID>> wrote:
>>
>> My environmental CLASSPATH is set to .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar
>> I can't run anythhing anymore. I can compile this FillTestField file but I can't run it. Or anything else. Not even Welcome.Class. I keep getting "Could not find or load main class FillTestField" I have tried:Changing the classpath to .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar;C:\Users\Dad\Downloads .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar;.;C:\Users\Dad\Downloads
>> .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar;C:\Users\Dad\Downloads\FillTestField.class
>> or from the prompt line: java -cp . FillTestField (from same folder where file is)java -cp C:\Users\Dad\Downloads\FillTestField (With this one I got a whole list of java help commands, etc)
>> Any ideas? Thanks for all your help.
>> //FillTestFieldpackage org.apache.pdfbox.examples.acroforms;import java.io.File;
>> import java.io.IOException;
>> import org.apache.pdfbox.pdmodel.PDDocument;
>> import org.apache.pdfbox.exceptions.*;
>> import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;import org.apache.pdfbox.pdmodel.interactive.form.PDField;
>> import org.apache.pdfbox.pdmodel.interactive.form.PDTextbox;
>>
>> public class FillTestField {
>> public static void main(String[] args) throws IOException { String formTemplate = "Users/Dad/Desktop/TCRM/game plan 12-16.pdf"; String filledForm = "Users/Dad/JavaTest/game plan 12-16.pdf"; // load the document PDDocument pdfDocument = PDDocument .load(new File(formTemplate),null);
>> // get the document catalog PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm(); // as there might not be an AcroForm entry a null check is necessary if (acroForm != null) { // Retrieve an individual field and set it's value. PDTextbox field = (PDTextbox) acroForm.getField( "Goal" ); field.setValue("Text Entry"); // If a field is nested within the form tree a fully qualified name // might be provided to access the field. field = (PDTextbox) acroForm.getField( "fieldsContainer.nestedSampleField" ); field.setValue("Text Entry"); }
>> // Save and close the filled out form.
>> //pdfDocument.save(filledForm); pdfDocument.close();
>> }
>> }
>
Re: Could not find or load main class
Posted by John Hewson <jo...@jahewson.com>.
Hi Lorena,
You provably need to read an introductory book on Java. These sorts of questions
aren’t really suitable for the PDFBox mailing list.
Or, if you’re in a hurry, try Googling the error message:
https://www.google.com/#q=Could+not+find+or+load+main+class
Thanks,
-- John
> On 14 Jan 2015, at 09:25, Lorena Leishman <lo...@yahoo.com.INVALID> wrote:
>
> My environmental CLASSPATH is set to .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar
> I can't run anythhing anymore. I can compile this FillTestField file but I can't run it. Or anything else. Not even Welcome.Class. I keep getting "Could not find or load main class FillTestField" I have tried:Changing the classpath to .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar;C:\Users\Dad\Downloads .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar;.;C:\Users\Dad\Downloads
> .;C:\Users\Dad\Downloads\pdfbox-app-1.8.8.jar;C:\Users\Dad\Downloads\FillTestField.class
> or from the prompt line: java -cp . FillTestField (from same folder where file is)java -cp C:\Users\Dad\Downloads\FillTestField (With this one I got a whole list of java help commands, etc)
> Any ideas? Thanks for all your help.
> //FillTestFieldpackage org.apache.pdfbox.examples.acroforms;import java.io.File;
> import java.io.IOException;
> import org.apache.pdfbox.pdmodel.PDDocument;
> import org.apache.pdfbox.exceptions.*;
> import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;import org.apache.pdfbox.pdmodel.interactive.form.PDField;
> import org.apache.pdfbox.pdmodel.interactive.form.PDTextbox;
>
> public class FillTestField {
> public static void main(String[] args) throws IOException { String formTemplate = "Users/Dad/Desktop/TCRM/game plan 12-16.pdf"; String filledForm = "Users/Dad/JavaTest/game plan 12-16.pdf"; // load the document PDDocument pdfDocument = PDDocument .load(new File(formTemplate),null);
> // get the document catalog PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm(); // as there might not be an AcroForm entry a null check is necessary if (acroForm != null) { // Retrieve an individual field and set it's value. PDTextbox field = (PDTextbox) acroForm.getField( "Goal" ); field.setValue("Text Entry"); // If a field is nested within the form tree a fully qualified name // might be provided to access the field. field = (PDTextbox) acroForm.getField( "fieldsContainer.nestedSampleField" ); field.setValue("Text Entry"); }
> // Save and close the filled out form.
> //pdfDocument.save(filledForm); pdfDocument.close();
> }
> }