Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8037351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:54:19+00:00 2026-06-05T02:54:19+00:00

I am attempting to run the following Java code on an Ubuntu system. The

  • 0

I am attempting to run the following Java code on an Ubuntu system. The code should create a blank PDF file using the pdfbox class:

import org.apache.pdfbox.pdmodel.*;
import java.io.*;

public class BlankPDF {
    public static void main(String[] args) {
        PDDocument doc = null;
        try{
            doc = new PDDocument();
        } catch (IOException ie){
            System.out.println(ie);
        }
        doc.addPage(new PDPage());
        try{
            doc.save("Empty PDF.pdf");
            doc.close();
        } catch (Exception io){
            System.out.println(io);
        }
    }
}

I have the following class dependencies in the same directory as the script:

  • pdfbox-1.7.0.jar
  • jempbox-1.7.0.jar
  • fontbox-1.7.0.jar
  • commons-logging-1.1.1.jar

I used the following command to compile the script:

sudo javac BlankPDF.java -classpath pdfbox-1.7.0.jar:fontbox-1.7.0.jar:jempbox-1.7.0.jar:commons-logging-1.1.1.jar

Which returned no output and created a .class file (indicating that the compilation worked correctly?)

But when I attempt to run the code using the following command:

sudo java BlankPDF -classpath pdfbox-1.7.0.jar:fontbox-1.7.0.jar:jempbox-1.7.0.jar:commons-logging-1.1.1.jar

I get this error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/pdfbox/pdmodel/PDDocument
    at BlankPDF.main(BlankPDF.java:15)
Caused by: java.lang.ClassNotFoundException: org.apache.pdfbox.pdmodel.PDDocument
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    ... 1 more

What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:54:21+00:00Added an answer on June 5, 2026 at 2:54 am

    The name of the class must be the last argument to java. The flags must precede it. If you put flags at the end of the command lines, as here, they are ignored. So:

    java -classpath .:pdfbox-1.7.0.jar:fontbox-1.7.0.jar:jempbox-1.7.0.jar:commons-logging-1.1.1.jar BlankPDF
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to run TextTransform.exe to generate code using a T4 template file. The
I'm attempting to run the following command in PHP (on Ubuntu): <?php if (exec(/home/johnboy/ffmpeg/ffmpeg
I am attempting to run a stored procedure from Java using Connector/J on a
I'm using gvim and rails.vim and getting the following error when attempting to run
I am attempting to run the following code snippet: var myVar1 = $.getJSON('myurl', function(json)
I run into an InvalidOperationException when attempting to run this code. Example Code using
When attempting to run the following assembly program: .globl start start: pushq $0x0 movq
I am attempting to run the following command in KornShell (ksh): set -A INDEXES
I am attempting to create a standalone ant build file for android. We are
I am getting the following error message when compiling or attempting to run my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.