aspose file tools*
The moose likes Linux / UNIX and the fly likes Jar file accessing folder Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Jar file accessing folder" Watch "Jar file accessing folder" New topic
Author

Jar file accessing folder

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
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

Joined: Jul 26, 2007
Posts: 10376
    
    8

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,

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
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

Joined: Jul 26, 2007
Posts: 10376
    
    8

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

Joined: Apr 11, 2005
Posts: 744
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

Joined: Jul 26, 2007
Posts: 10376
    
    8

Can you put logging/printf statements before and after the "access" part
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3829

Have you tried both these approaches in Windows and they both worked the same way?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: Apr 11, 2005
Posts: 744
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

Joined: Apr 11, 2005
Posts: 744
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

Joined: Jul 26, 2007
Posts: 10376
    
    8

It will help us help you better if you can post your SSCCE code
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jar file accessing folder