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 1077271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:33:03+00:00 2026-05-16T21:33:03+00:00

I’m trying to do something very simple. All I want to do at this

  • 0

I’m trying to do something very simple. All I want to do at this moment is build a file that contains the appropriate classes.

I have a file called Promomon.java

class Promomon {
  public static void main(String[] args)
  {
    System.out.println("Hello World!");
  }
}

Simple simple, everything is fine there. I can compile and run and I see Hello World!.

Now I add the classes that I wish to use.

import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

That was taken straight from the Apache POI docs.

  • I am using Ubuntu 10.04. I installed java using synaptic (apt-get install openjdk-6-jdk)
  • Java is installed at /usr/lib/jvm/java-6-openjdk/jre/
  • JAVA_HOME is set to “/usr/lib/jvm/java-6-openjdk/jre/”

    $ echo $JAVA_HOME
    /usr/lib/jvm/java-6-openjdk/jre/

  • I built POI jars myself using Ant, no problem there.

  • I placed the jars into java’s lib directory. (/usr/lib/jvm/java-6-openjdk/jre/lib/)

    $ ls -l /usr/lib/jvm/java-6-openjdk/jre/lib/poi*
    -rw-r–r– 1 root root 1539296 2010-09-08 12:40 /usr/lib/jvm/java-6-openjdk/jre/lib/poi-3.6-20100908.jar
    -rw-r–r– 1 root root 69142 2010-09-08 12:40 /usr/lib/jvm/java-6-openjdk/jre/lib/poi-contrib-3.6-20100908.jar
    -rw-r–r– 1 root root 181907 2010-09-08 12:40 /usr/lib/jvm/java-6-openjdk/jre/lib/poi-examples-3.6-20100908.jar
    -rw-r–r– 1 root root 412788 2010-09-08 12:40 /usr/lib/jvm/java-6-openjdk/jre/lib/poi-ooxml-3.6-20100908.jar
    -rw-r–r– 1 root root 3774336 2010-09-08 12:40 /usr/lib/jvm/java-6-openjdk/jre/lib/poi-ooxml-schemas-3.6-20100908.jar
    -rw-r–r– 1 root root 795893 2010-09-08 12:40 /usr/lib/jvm/java-6-openjdk/jre/lib/poi-scratchpad-3.6-20100908.jar

  • My classpath is set to this directory.

    $ echo $CLASSPATH
    /usr/lib/jvm/java-6-openjdk/jre/lib/

What on earth am I doing wrong? I also tried using the pre-built binaries, no change.

Thanks for you help!

  • 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-05-16T21:33:03+00:00Added an answer on May 16, 2026 at 9:33 pm

    When you specify jars in the classpath you can’t just specify the directory they’re in, you need to list the jars explicitly (the change Jon Skeet refers to in jdk6 may be a change this but I don’t remember it either).

    I wouldn’t put those jars in the jdk lib directory. Make a lib directory next to the src directory for your Promomon.java file, add your jars to that, and list the jars individually in the classpath when you compile and run. And when I say classpath I don’t mean the environment variable. Here are some alternatives:

    • create a couple of executable files that contain the compile and run commands and add the jar files to the list of stuff in the -cp switch.
    • Get ant and make a build.xml file.
    • Use an IDE like eclipse and specify the jars (in the Eclipse menu pick File->BuildPath->Configure Build Path and pick the “Libraries” tab).

    Going from “Hello World” to a program that uses third-party libraries is a big step with Java. The simple approach to getting something compiled and running stops working fast.

    BTW I looked it up here and the JDK6 change is that you can use wildcards in the classpath, so instead of listing the jars individually like

    -cp=/usr/myapp/classes:/usr/myapp/lib/foo.jar:/usr/myapp/lib/bar.jar
    

    you can say

    -cp=/usr/myapp/classes:/usr/myapp/lib/*.jar
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.