• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Jar file accessing folder

 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried both these approaches in Windows and they both worked the same way?
 
Sheriff
Posts: 28328
96
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It will help us help you better if you can post your SSCCE code
 
What are you doing? You are supposed to be reading this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic