This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes code compiles with no errors but doesn't not create a class with pdf fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "code compiles with no errors but doesn Watch "code compiles with no errors but doesn New topic
Author

code compiles with no errors but doesn't not create a class with pdf fields

Zubi Pen
Greenhorn

Joined: Oct 24, 2007
Posts: 26
I hava a PdfFormGenerator.java file that takes a pdf document
loops throught all the fields and creates a class file and converts
the fieldnames into something java can use in a method name,. basically
sets all the set and get method.

I have specified the location of my pdf form and the location of my java code. The file
compiles with no errors, however when I run the file I get the following msg and it
doesn't create the class file

PdfFormGenerator : 0
java.lang.ArrayIndexOutOfBoundsException: 0
at hsc.student.PdfFormGenerator.main(PdfFormGenerator.java:138)
Press any key to coninue...

Any ideas how I can get this to work. Thanks

Here is the code:

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19557
    
  16

PdfFormGenerator gen = new PdfFormGenerator(args[0], args[1]);

This means the program expects at least two arguments on the command line. Any less and it will throw the error you've seen. Considering index 0 is already invalid you have given no arguments at all.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3169
    
  10
Are you passing any arguments when you call the program ?
Your mainmethod is expecting two arguments which it passes to the PdfFormGenerator constructor.


Joanne
Zubi Pen
Greenhorn

Joined: Oct 24, 2007
Posts: 26
How can I pass the two arguments to the PdfFormGenerator constructor, I think I need to pass the Form name and the class name but I thought I did do that in the PdfFormGenerator Constructor on line 3 and 4:



Thanks for the replies,
Zub
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19557
    
  16

Yes, but in the constructor, you still expect two Strings. You try to get these strings from the command line arguments, but you haven't given any.

Basically, you are calling it similar to this:

Instead, you should call it as this:

[ November 01, 2007: Message edited by: Rob Prime ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: code compiles with no errors but doesn't not create a class with pdf fields
 
Similar Threads
java code for pswd protection+digital sign (for all pgs)
how can do I run this java code and pass the pdf file ?
java program to password protect a signed pdf file
complex XML doct & SAX parsing
how to change existing pdf font encoding (multi language) dynamically