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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:44:15+00:00 2026-05-18T12:44:15+00:00

I am trying to create a simple console based java application, which requires users

  • 0

I am trying to create a simple console based java application, which requires users to select files from their local filesystem.

The console prompts the user to select one of the available options and then switches on the input given.

public Client() throws UnknownHostException, IOException {
    printuseroptions();
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    char userdecision = br.readLine().charAt(0);

    System.out.println(userdecision);

    switch(userdecision){
        case '1':
            System.out.println("Which file would you like to open?");
            openfile(br.readLine());
            break;
        case '2':
            System.out.println("Which file would you like to close?");
            closefile(br.readLine());
            break;
        }

private boolean openfile(String path){
    System.out.println("openfile("+path+")");
    return false;
}

private boolean closefile(String path){
    System.out.println("closefile("+path+")");
    new JFileChooser().showOpenDialog(null);
    return false;
}

No matter what I do, the JFileChooser pop up box will not open. No error is shown on the console, but a debug step-through shows the following error:

Blockquote
Thread [main] (Suspended)
ClassNotFoundException(Throwable).(String, Throwable) line: 217
ClassNotFoundException(Exception).(String, Throwable) line: not available
ClassNotFoundException.(String) line: not available
URLClassLoader$1.run() line: not available
AccessController.doPrivileged(PrivilegedExceptionAction, AccessControlContext) line: not available [native method]
Launcher$ExtClassLoader(URLClassLoader).findClass(String) line: not available
Launcher$ExtClassLoader.findClass(String) line: not available
Launcher$ExtClassLoader(ClassLoader).loadClass(String, boolean) line: not available
Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available
Launcher$AppClassLoader.loadClass(String, boolean) line: not available
Launcher$AppClassLoader(ClassLoader).loadClass(String) line: not available
ResourceBundle$RBClassLoader.loadClass(String) line: not available
CoreResourceBundleControl(ResourceBundle$Control).newBundle(String, Locale, String, ClassLoader, boolean) line: not available
ResourceBundle.loadBundle(CacheKey, List, Control, boolean) line: not available
ResourceBundle.findBundle(CacheKey, List, List, int, Control, ResourceBundle) line: not available
ResourceBundle.getBundleImpl(String, Locale, ClassLoader, ResourceBundle$Control) line: not available
ResourceBundle.getBundle(String, ResourceBundle$Control) line: not available
Toolkit$3.run() line: not available
AccessController.doPrivileged(PrivilegedAction) line: not available [native method]
Toolkit.() line: not available
Component.() line: not available
Client.closefile() line: 90
Client.() line: 60
Client.main(String[]) line: 36

The same code runs perfectly on a Linux 32 bit machine, so I suspect the problem is Windows related.

The code below runs as expected on both Windows and Linux so I suspect might be due to the different ways in while console input is handled in Windows vs Linux (CR LF).

import javax.swing.JFileChooser;

public class Example {
    public static void main(String[] args) {
        new JFileChooser().showOpenDialog(null);
    }
}

Thanks

  • 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-18T12:44:16+00:00Added an answer on May 18, 2026 at 12:44 pm

    It looks like you’re just as new here as I am. 😉 Let’s see if I can help.

    I made changes to your code to get it to compile, and ran it on a Windows Server 2003 x64 machine, and didn’t see any problems – the file chooser dialog opens.

    I suggest two things you can do to eliminate other possibilities:

    1) Ensure the system’s native look & feel is set. Set your look & feel to the system default by using this when your program starts: UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

    2) Ensure you only construct and open your JFileChooserDialog, and all other Swing components, inside the Event Dispatch Thread (EDT). If you know the current thread is the main thread or some other worker thread (and I assume it is because you’re taking console input), you need to call SwingUtilities.invokeLater(Runnable) for correct execution.

    Good luck with that.

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

Sidebar

Related Questions

I am trying to create a simple ConsoleApplication in which i would like to
I am trying to create a simple dialog in MFC using Visual C++. My
I am trying to create a simple page that enters data in to a
I'm trying to create a simple BaSH-like grammar on ANTLRv3 but haven't been able
I'm trying to create a simple toggling sidebar using jquery, where it expands and
I'm playing with the ASP.NET MVC Framework, trying to create a simple site. My
I am trying to create a rather simple effect on a set of images.
I'm new to postgreSQL and I have a simple question: I'm trying to create
Im using Eclipse 3.4, EclipseMe 1.7.9. Im trying to deploy/create package a simple project
I'm trying to come up with a simple and efficient way to create a

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.