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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:08:32+00:00 2026-06-04T11:08:32+00:00

So I have the following code: File txtFileDir = new File(MAIN_DIR + test); FilenameFilter

  • 0

So I have the following code:

File txtFileDir = new File(MAIN_DIR + "test");
FilenameFilter filter = new FilenameFilter() {
    @Override
    public boolean accept(File dir, String name) {
        return name.endsWith(".txt");
    }
}; 
File[] txtFiles = txtFileDir.listFiles(filter);

and it works fine on my development machine which uses windows with Java 1.6 installed. However, when I port the class over to the unix box it’s going to run on and try to run it I get a ClassNotFoundException on the FilenameFilter line. The unix box has Java 1.6 on it as well so I don’t know what the problem could be. It’s not a huge deal as there are multiple ways to accomplish this same thing, but I’m just curious if anyone has any thoughts on why it wouldn’t work on the unix box.

I did try compiling the code on the unix box too in order to see if that made any difference but it didn’t. The code compiles fine on the unix box but I still receive the same error. Anyone have any thoughts?

UPDATE

I figured out the issue. Apparently when I compiled the code with that class in it, it created an additional .class file with the name of my class and $1 appended onto it. So I had Test.class and Test$1.class. Once I kept the Test$1.class file things worked properly. I’m guessing it needs that second class file because of the inner class I created? At least I think that’s an inner class.

Anyway, thanks for the help all.

  • 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-04T11:08:33+00:00Added an answer on June 4, 2026 at 11:08 am

    As stated in the comment, you should first verify that you are using same version as another machine.
    Another way to check whether FilenameFilter is there in your path is :

    javap java.io.FilenameFilter

    so if above command list the classname and methods of FilenameFilter as

    Compiled from "FilenameFilter.java"
    public interface java.io.FilenameFilter{
        public abstract boolean accept(java.io.File, java.lang.String);
    }
    

    then FilenameFilter is there in your path and do not need to worry about version.

    But if it’s giving you error then simplest way would be to copy rt.jar which contains almost all (absolute necessary) class files and replace it with your existing rt.jar, which might be there in /usr/include/jvm/.... or you can find it (do not forget to make backup, you can also check whether FilenameFilter.class exists in rt.jar by extracting it and going through java/io/)

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

Sidebar

Related Questions

I have the following code in my file: unsigned char * pData = new
Very simply put, I have the following code snippet: FILE* test = fopen(C:\\core.u, w);
I have following code to serialize my data into a file: out = new
I have following code in web aplication java.​awt.Desktop.getDesktop().print(new File(path)); It is working with any
I have the following json code file named: sections.json { section1: { priority: 1,
I have following code: os.chdir(os.path.dirname(os.path.realpath(__file__)) + /../test) path.append(os.getcwd()) os.chdir(os.path.dirname(os.path.realpath(__file__))) Which should add /../test to
I have the following code reading a file containing unicode text (Japanese). File f
When I using the following code to read file: lines=file(data.txt).read().split(\n) I have the following
I have the following code which reads in the follow file, append a \r\n
I have the following code: if (include_once(dirname(__FILE__).'/file.php') || include_once(dirname(__FILE__).'/local/file.php') ) { This causes an

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.