Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-17-2008, 09:36 PM
Member
 
Join Date: Jan 2008
Location: South Africa
Posts: 18
jimm1 has a little shameless behaviour in the past
Problem locating resources on Linux.
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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-18-2008, 07:34 PM
Member
 
Join Date: Jan 2008
Location: South Africa
Posts: 18
jimm1 has a little shameless behaviour in the past
OK Ive fixed the problem. I used a Shell-Script to launch the JAR, and then of course the shell-script automatically sets the working directory correctly. Is it common practice to use shell-scripts to launch Java programs in Linux, or using Batch files to launch Jar's on windows? I noticed on Linux that NetBeans uses a shell-script to launch. Any advice?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem loading resources. jimm1 Advanced Java 6 06-23-2008 08:31 PM
[SOLVED] Problem with setVisible(); on LINUX lepetitprince AWT / Swing 6 04-07-2008 03:14 PM
Windows Linux conflict - TrayIcon image not display in Linux Eranga Advanced Java 0 03-25-2008 06:37 AM
problem locating file in web application Rem New To Java 0 11-09-2007 05:00 PM
problem with ServerSocket on Linux gabriel New To Java 1 08-07-2007 05:46 PM


All times are GMT +3. The time now is 05:14 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org