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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:50:17+00:00 2026-05-23T15:50:17+00:00

In my code at a certain point i have this code void selectRoot() {

  • 0

In my code at a certain point i have this code

void selectRoot() {
        JFileChooser ch = new JFileChooser();
        ch.showOpenDialog((JFrame)this);
    }

This throws that Exception:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at java.io.Win32FileSystem.normalize(Win32FileSystem.java:164)
    at java.io.Win32FileSystem.getUserPath(Win32FileSystem.java:296)
    at java.io.Win32FileSystem.resolve(Win32FileSystem.java:312)
    at java.io.File.getAbsolutePath(File.java:501)
    at sun.awt.shell.Win32ShellFolder2.<init>(Win32ShellFolder2.java:291)
    at sun.awt.shell.Win32ShellFolderManager2.createShellFolderFromRelativePIDL(Win32ShellFolderManager2.java:66)
    at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Win32ShellFolderManager2.java:56)
    at sun.awt.shell.Win32ShellFolderManager2.getRecent(Win32ShellFolderManager2.java:114)
    at sun.awt.shell.Win32ShellFolderManager2.get(Win32ShellFolderManager2.java:251)
    at sun.awt.shell.ShellFolder.get(ShellFolder.java:227)
    at sun.swing.WindowsPlacesBar.<init>(WindowsPlacesBar.java:64)
    at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.updateUseShellFolder(WindowsFileChooserUI.java:505)
    at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(WindowsFileChooserUI.java:196)
    at javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserUI.java:136)
    at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(WindowsFileChooserUI.java:129)
    at javax.swing.JComponent.setUI(JComponent.java:673)
    at javax.swing.JFileChooser.updateUI(JFileChooser.java:1763)
    at javax.swing.JFileChooser.setup(JFileChooser.java:360)
    at javax.swing.JFileChooser.<init>(JFileChooser.java:333)
    at javax.swing.JFileChooser.<init>(JFileChooser.java:286)
    at my.pack.Main.selectRoot(Main.java:184)

Looking in the source of java.io.Win32FileSystem.normalize() it seems the (current) path is null:

   public String normalize(String path) {
        int n = path.length(); // Line: 164
        char slash = this.slash;
        char altSlash = this.altSlash;

If i run selectRoot() from another point in the program it runs fine …

Update

Guys that is really a good one for the great book of programing pitfalls !

In my original code there is a JTextField that holds the actual path and get initialize that way:

root = new JTextField();
root.setToolTipText("Root folder");
root.setText(System.clearProperty("user.dir"));

System.clearProperty() clears the system property (to null) and returns the old value (arrrghhhhhhh). clearProperty() probably slipped in from auto-completion.

Thank you all. Will give some up votes to you …

  • 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-23T15:50:18+00:00Added an answer on May 23, 2026 at 3:50 pm

    maybe this will help

    new JFileChooser(System.getProperty("user.home"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that looks like this: public class A { public void doStuff()
I have certain critical bash scripts that are invoked by code I don't control,
I have a workflow, that at a certain point, needs to be triggered recursively.
This is the code I currently have. timer = new Timer(Integer.parseInt(ms.getText()), new ActionListener() {
I have a small program that should move the mouse to a certain point
I am writing certain code in MIPS and I've come to the point where
I have a situation where I want certain code to be executed no matter
I got a code that will match a certain block of IP and redirect
This code works fine to find an available room within certain date, but it
So I'm working with PostSharp to pull out boilerplate logging/exception handling code so that

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.