Hi, I'm 16, live in South Africa, and new to this forum, and have a simple problem. Let me first give you a basic overview of my program.
It was made in NetBeans. I use Linux Ubuntu Gutsy Gibbon 7.10.
It is called TaskOrganiser, which I want to use for managing school task's which I am assigned, and keep track of them. So I created my program, and organized it into a single JAR file, called TaskOrganiser.jar. This JAR contains a folder called META-INF, which contains the manifest file. The manifest file states the main-class, and states a class-path as "lib/AbsoluteLayout.jar". It then also contains the package "taskorganiser" and a couple of classes, such as "TaskWindow", "TaskList", "Task", "TaskGenerator", "Subject"(Enum), etc.
The JAR was automatically created by NetBeans. This JAR is located in a folder now call TaskOrganiser, and inside this folder is also the "Lib" folder with AbsoluteLayout class, and another folder call "tasks", which is where I keep all my saved tasks (as a serialized object). Now here comes the problem.
When I want to load my program, navigate to the directory via the shell, and type "java -jar TaskOrganiser.jar", the program executes fine and loads all the tasks. However, if I navigate to the folder using the graphical folder browser, then double click on the program, it runs, but however cannot load the tasks. When I placed the tasks folder into my home directory, it loaded them. This leads me to believe that it sets the current directory as my home directory, and searches "tasks" folder in there. This is wrong. I want to be able to load my program and its resources by clicking on it (Or even better, creating a launcher for it on my app menu), but I do not want to keep my "tasks" folder in my home directory. I want it to stay in the same folder as my JAR file. I first though of hard-coding the locations of the tasks like "/home/james/java/taskorganiser/tasks/tasklist.bin", as opposed to "tasks/tasklist.bin", but that would not be ideal. It would not work on any other computers, or on other operating systems. The only way past this problem is somehow obtaining the path of the folder which my JAR is in, then prefixing that in every file, but this is far from elegant. Any way to fix this problem? It is driving me nuts, and I'm relatively new to programming.
