• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Permission denied trying to access file via terminal

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to compile code in two different packages. It's super simple code - literally just packagea with ClassA, which does nothing, and packageb, which imports packagea.ClassA & is supposed to print a message. I'm getting this error message:

-bash: tmp/packagea/ClassA.java: Permission denied

No idea why. Any ideas?
 
Valentine Wiggins
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's my specific code:

This is named ClassA.java and is in a folder named packagea.


This is named ClassB.java and is in a folder named packageb.


Both packagea and packageb are in a folder named tmp.
 
Sheriff
Posts: 7126
185
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'm getting this error message:


Doing what?  Meaning, what did you execute and where?

-bash: tmp/packagea/ClassA.java: Permission denied  


This looks like a Bash shell error.  Are you trying to execute the .java file?  Because that won't work; you need to compile it with javac first.
 
Valentine Wiggins
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:

I'm getting this error message:


Doing what?  Meaning, what did you execute and where?



Ok - I tried again and now I'm getting a different error. This is exactly what I typed in, and the code is what I posted above.

Valentines-MacBook-Air:Desktop Valentine$ javac tmp/packagea/ClassA.java tmp/packageb/ClassB.java;
tmp/packageb/ClassB.java:5: error: cannot find symbol
classA a;
^
 symbol:   class classA
 location: class ClassB
1 error
 
Valentine Wiggins
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Noticed that I had  classA instead of ClassA. So now it compiles, but sends an error message saying it can't find the main for ClassB.

Valentines-MacBook-Air:Desktop Valentine$ javac tmp/packagea/ClassA.java tmp/packageb/ClassB.java;
Valentines-MacBook-Air:Desktop Valentine$ java tmp/packageb.ClassB;
Error: Could not find or load main class tmp.packageb.ClassB
 
author & internet detective
Posts: 42135
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not cd into the "tmp" directory so you don't have to deal with the slashes?

IN any case, you need to specify the classpath when you run ClassB so Java knows where to look for ClassA. For example:

 
reply
    Bookmark Topic Watch Topic
  • New Topic