I have looked over several other answers on this site trying to understand why this might be happening, but I don't understand what I'm doing wrong.
I am trying to get started with iText, and .jar files in general. I downloaded and extracted the iText .jar files to a folder on my desktop: Desktop\Java\itext-5.4.4\"jar files here"
I then went to the following site:
http://tutorials.jenkov.com/java-itext/getting-started.html
and copied the code into Notepad. It looks like this:
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
/**
*/
public class HelloWorldExample {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter.getInstance(document,
new FileOutputStream("HelloWorld.pdf"));
document.open();
document.add(new Paragraph("A Hello World PDF
document."));
document.close(); // no need to close
PDFwriter?
} catch (DocumentException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
I saved the file on my desktop as HelloWorldExample.java
I then went to compile my code with the following commands:
cd c:\desktop
javac -classpath Java\itext-5.4.4\itextpdf-5.4.4.jar HelloWorldExample.java
This compiled successfully
I then tried:
java -classpath Java\itext-5.4.4\itextpdf-5.4.4.jar HelloWorldExample
And I get the Error: Could not find or load main class HelloWorldExample error.
I have tried many variations on this including making a folder, placing a lib folder in that folder, and creating a package, but still get the same error.
What is happening here?
Thanks!