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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:06:00+00:00 2026-06-18T04:06:00+00:00

Summary Java environment variables correctly set, as seen from echo-ing them. However, jars are

  • 0

Summary

Java environment variables correctly set, as seen from echo-ing them. However, jars are only seen when explicitly included with javac command.

Details

This is not specifically related to graphics and OpenGl, certain the problem is related to classpaths, ie the importing of third-party jar files.

Using Windows XP SP3, JDK 1.7.0_13

On Windows xp, the system environment variables PATH/JAVA_HOME/CLASSPATH have been set/added-to to include these directories:

C:\Documents and Settings\Administrator\My Documents\project\jar;
C:\Java\jdk1.7.0_13;
C:\Java\jdk1.7.0_13\bin;
C:\Java\jdk1.7.0_13\lib;

There are no user-defined variables which may be conflicting.
Assurance from the Terminal (which I restarted after changing the environment variables so that it would be updated, to set environment variables in windows xp, see Environment variables for java installation):

>echo %classpath%
  C:\Documents and Settings\Administrator\My Documents\project\jar;C:\Java\jdk1.7.0_13;C:\Java\jdk1.7.0_13\bin;C:\Java\jdk1.7.0_13\lib;

>echo %java_home%
  C:\Documents and Settings\Administrator\My Documents\project\jar;C:\Java\jdk1.7.0_13;C:\Java\jdk1.7.0_13\bin;C:\Java\jdk1.7.0_13\lib;

>echo %path%
  C:\WINDOWS\System32;... ...C:\Java\jdk1.7.0_13;C:\Java\jdk1.7.0_13\bin;C:\Java\jdk1.7.0_13\lib;C:\Documents and Settings\Administrator\My Documents\project\jar;

Overkill, yes… when it works I’ll trim them appropriately

Relevant files:

C:\Documents and Settings\Administrator\My Documents\project\jar\jogl-all.jar
C:\Documents and Settings\Administrator\My Documents\project\Mush.java

C:\Documents and Settings\Administrator\My Documents\project\JarDir.java

jogl-all.jar contains “javax.media.opengl.GL2”, Mush.java is a program which displays simple 3D mushrooms through importing java-OpenGL libraries; specifically it imports “javax.media.opengl.GL2”.

JarDir.java is a program I found at http://www.java2s.com/Code/Java/File-Input-Output/Listfilesinajarfile.htm which shows what classes are within a jar, I am using it to prove the jar contents. It also demonstrates that compilation is possible on the machine.

JarDir.java is as follows:

import java.io.*;
   import java.util.*;
   import java.util.jar.*;

   public class JarDir {
     public static void main (String args[]) 
         throws IOException {

       JarFile jarFile = new JarFile("C:\\Documents and Settings\\Administrator\\My Documents\\project\\jar\\jogl-all.jar");
       Enumeration enumy = jarFile.entries();
       while (enumy.hasMoreElements()) {
         process(enumy.nextElement());
       }
     }

     private static void process(Object obj) {
       JarEntry entry = (JarEntry)obj;
       String name = entry.getName();
       long size = entry.getSize();
       long compressedSize = entry.getCompressedSize();
       System.out.println(
           name + "\t" + size + "\t" + compressedSize);
     }
   }

and gives the output:

>javac JarDir.java

>java JarDir
... (lots of stuff)
javax/media/opengl/GL2.class   94123   28513
... (lots of stuff)

which demonstrates successful compilation and the presence of the class within the jar file. Attempting to run Mush.java gives many errors, significantly the first one:

>javac Mush.java
Mush.java:21: error: package javax.media.opengl does not exist:
import javax.media.opengl.GL2;
                         ^

To determine if this was a classpath problem, I ran:

>javac Mush.java -cp ./jar/jogl-all.jar

Which gave errors based on the lack of presence of related classes (such as MushScene.java which is instantiated by Mush.java and lives in the same project folder …) BUT no problems in finding javax.media.opengl ! So the problem must be an environment variable problem!

This then means, that although according to echo %classpath% the classpath is set correctly, java disagrees. What have I done wrong?

Note: the Mush.java program has demonstratively worked on Linux.

Note2: I have multiple jars, if I end up using N jars within the jar folder, I’d like to be able to include the folder, rather than naming each jar specifically =)

  • 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-18T04:06:01+00:00Added an answer on June 18, 2026 at 4:06 am

    jogl-all.jar is not in your CLASSPATH environment variable. So obviously, javac can’t find any class from this jar if you don’t include it explicitely in the -cp option. The jar itself must be in the CLASSPATH, and not the directory containing it. just like in the -cp option.

    I wouldn’t use a global CLASSPATH environment variable anyway, but only the -cp option. It will make everything easier when you’ll compile or run another Java project, with different dependencies.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question : How do I correctly use java.util.locale for checking a user's locale? Summary
i'am trying to get the summary information from file with JAVA and I can't
Executive summary: how do I install a new root certificate into Java using Java
Summary : is there a way to get the unique lines from a file
Here is the summary: I need to build a simple java web app that,
any help greatly appreciated. Problem: Ubuntu 11.10 not playing nice with Java's JOGL Summary
I have some JNI code in a thread that calls from Java to C.
Short, at-a-glance summary of question (TLDR): how do I ensure a Java Object is
The java code sample below uses a java DelayQueue to process tasks. However the
I am trying to set up a lein build environment on Windows 7 haven

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.