Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jar file accessing folder

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I just switched over to linux mint 10(gnome, 32 bit).

I have a jar file on my desktop that needs to access a folder on my desktop, but when I run the jar, the folder is not picked up by it.

I tried changing permissions on the folder, but it made no difference.

Is there anything I can do?

Also in windows, theres a program called Jexecutor, converts jars into exe files, but the demo displays a console with the program output which I use when running jar files.
Is there anything similar in linux so I can see the program output when its run as a jar file?

Thanks very much for any help.
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your jar executing? How are you confirming it is executing? What do you mean "not getting picked up". Do you get any Access Denied or some other exception?

Is there anything similar in linux so I can see the program output when its run as a jar file?

Try launching the jar from the console using java -jar MyJar.jar,
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks..

Its a little strange, the folder is accessed fine when I run from terminal, but when i just open jar, then it doesn't access it, so I can't tell if theres any exceptions going on.

Any thoughts?

 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well now that the probable permission issue is sorted out and the file does exist, what do you mean by "access it". What is it that your code does when you say "access it".
Is your app a GUI app? Can you put logging/printf statements before and after the "access" part?
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well the folder contains images, which the program places on the side of a rubik's cube.

When I run the jar from the terminal, the images show up, and the text output in terminal is normal.


But when I just run the jar by clicking and opening with java 6 runtime, the program runs, but the images don't show up.
Of course there is no output for me to read as I'm not running from terminal.

I suppose I could get the error to be displayed in the gui, but a bit of hassle to do that.

Any ideas?
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you put logging/printf statements before and after the "access" part
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried both these approaches in Windows and they both worked the same way?
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
colin shuker wrote:I suppose I could get the error to be displayed in the gui, but a bit of hassle to do that.

Any ideas?


You need to see the error messages to find out what the problem is. At this point we still have almost no information about the problem, but my guess would be that your code is making an incorrect assumption about what the current working directory is. But really, fix your code so you can see the error messages. You could display them in the GUI or just write them to a file. (When defining this file use the full path name, not a relative path name.)
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works fine in windows, I'll try writing to file.

I got a million other problems (well not quite a million):
Trying to use glassfish 3 in netbeans 6.9 on linux mint 10(32 bit), but can't get it to work.
But I have an apache2 server running already, so if I goto "localhost" on a browser, it displays some php.
I figured this would conflict with running glassfish, so I turned off the apache2, went back to browser...
and strangely the php files still run fine, so I don't have a clue.

For now, I'll try and printout the error(s)
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, well I got it to printout to file, but when I run as a jar file (with terminal or without) the text output won't show up.
Only seems to show when I run from eclipse.

So I donno, losing the will to live now..
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will help us help you better if you can post your SSCCE code
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic