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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:15:59+00:00 2026-05-15T07:15:59+00:00

I’m working through a ANTLR (a language processing library) book and there are many

  • 0

I’m working through a ANTLR (a language processing library) book and there are many examples that should be easy to compile using the command line.

Some information to get te problem:

antlr-3.2.jar contains the library classes. I added the antlr-3.2.jar to the CLASSPATH environment variable (Windows 7) and when compiling the classes with javac everything works fine.
This is what i execute to compile my program:

javac Test.java ExprLexer.java ExprParser.java

Test.java contains my main()-method whereas ExprLexer and ExprParser are generated by ANTLR. All three classes use classes contained in the antlr-3.2.jar. But so far so good. As I just said, compiling works fine.

It’s when I try to execute the Test.class that I get trouble.
This is what I type:

java -cp ./ Test

When executing this, the interpreter tells me that he can’t find the ANTLR-classes contained in the antlr-3.2.jar, altough I added an entry in the CLASSPATH variable.

Exception in thread "main" java.lang.NoClassDefFoundError: org/antlr/runtime/Cha
rStream
Caused by: java.lang.ClassNotFoundException: org.antlr.runtime.CharStream
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: Test.  Program will exit.

I’m using Windows 7 and Java 1.6_20. Can someone tell what is going on? Why will the interpreter not look in the jar-Archive I specified in the CLASSPATH?

I found some kind of workaroud. I copied the antlr-3.2.jar into the directory where the Test.class is located and then executed:

java -cp ./;antlr-3.2.jar Test

This worked out. But I don’t want to type the jar-Archive everytime I execute my test programs. Is there a possibility to tell the interpreter that he should automatically look into the archive?

  • 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-15T07:15:59+00:00Added an answer on May 15, 2026 at 7:15 am

    I’m using Windows 7 and Java 1.6_20.
    Can someone tell what is going on? Why
    will the interpreter not look in the
    jar-Archive I specified in the
    CLASSPATH?

    -cp on the commandline overrides the CLASSPATH variable. There is no convenient way to do what you’re trying to do. I’d suggest creating an ant script, shell script, or shell alias if you don’t want to type out the full classpath each time.

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

Sidebar

Ask A Question

Stats

  • Questions 431k
  • Answers 431k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You're setting videoFileName to the raw bytes of the videofile:… May 15, 2026 at 2:14 pm
  • Editorial Team
    Editorial Team added an answer edit: Sorry, there were a few errors with the properties… May 15, 2026 at 2:14 pm
  • Editorial Team
    Editorial Team added an answer That should do it. Works for me. Things to check:… May 15, 2026 at 2:14 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.