Java Working Directory

spuder picture spuder · Dec 4, 2012 · Viewed 15.8k times · Source

I'm pretty new to programming, so this should be an easy one. I'm switching from eclipse to netbeans and I am trying to add libjinput-osx.jnilib to my working directory. I have step by step instructions for eclipse, but not netbeans. I'm about 2.5 hours and 65 google searches in and I still cant find the answer to these two basic questions I have.

  1. What exactly is a working directory in java?
  2. How do you add a .jnilib file to your working directory in netbeans?

My end goal is to get an xbox controller to control a game of snake I wrote. I am trying to use JInput and this tutorial. In order to compile properly on OSX I need to put libjinput-osx.jnilib in the "working directory".

Answer

MadProgrammer picture MadProgrammer · Dec 4, 2012

The "working directory" is the location where the application is working in...cryptic huh ;)

Typically it's the launch location for the app, although this can be modified through flags and other process.

In Netbeans, the working directory is typically the root directory of the project (which contains the src and nbproject folder), but this can be changed via the project properties.

One of the simplest ways to find the working directory at run time (this is useful for testing) is to do some thing like...

System.out.println(new File(".").getAbsolutePath());