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

  • Home
  • SEARCH
  • 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 1108443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:05:01+00:00 2026-05-17T02:05:01+00:00

I have 2 java program located seperately One in c:\test and the other in

  • 0

I have 2 java program located seperately
One in c:\test and the other in c:\test\new

I can compile both of it without any error \javac

But when i try to execute the file \java
it shows the error like this

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at ButtonFrame.makeButton(ButtonTest3.java:42)
    at ButtonFrame.<init>(ButtonTest3.java:29)
    at ButtonTest$1.run(ButtonTest.java:17)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

i put this in my classpath

CLASSPATH value- C:\test;C:\test\new

but if i change the order of the value in CLASSPATH to this

CLASSPATH value- C:\test\new;C:\test

the error is simply gone

Why?? this could happening
Only the order matters?

  • 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-17T02:05:02+00:00Added an answer on May 17, 2026 at 2:05 am

    You’ve a class with the same name in the both folders. In C:\test there’s a version of the ButtonTest3 class which contains a programming bug causing this NullPointerException. In C:\test\new there’s a different version of the ButtonTest3 class which doesn’t contain this bug, or probably there’s a ButtonTest class which does entirely different things than the one in C:\test.

    Cleanup your classpath. It’s not good to have duplicate different versioned classes with the same signature in the classpath. If your intent is that new is supposed to be a package identifier, then you need to leave it away from the classpath. However, such a package name would have resulted in a compilation error, so that can’t be it.


    As to the bug, a NullPointerException is relatively trivial to naildown and fix. First look at the first line of the stacktrace:

    at ButtonFrame.makeButton(ButtonTest3.java:42)
    

    It’s telling that it has occurred in line 42 of ButtonTest3 class, inside the makeButton() method. Now go to line 42 of ButtonTest3.java, it’ll look something like:

    someObject.doSomething();
    

    Look there where a dot operator . is been used to invoke a method or access a field of some object. The NullPointerException means that someObject is null at the particular moment. There is no instance!

    It’s an easy fix: just ensure that it is not null at the moment you’re invoking/accessing it:

    someObject = new SomeObject();
    // ...
    someObject.doSomething();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java program with Maven managing its dependencies. One of those dependency
I have a HelloWorld.java located on my server, and I'd like to compile this
I have a Java program called Main.java, it is located in the following directory:
I have got the following code in a file called test.java which is located
There is a java program in the folder Downloads/jason/src/demo/de/l3s/jason/testfile.java I can compile it with
I have a java program that performs 5 different tasks. When I run the
I have a java program that is running in the background(Windows). I would like
I have a Java program that runs many small simulations. It runs a genetic
I have a Java program (call it Jack) and an Objective-C program (call it
I have a java program that will work with a variety of Java Beans.

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.