Forum Stats

  • 3,767,932 Users
  • 2,252,731 Discussions
  • 7,874,385 Comments

Discussions

JAVA under UNIX

843798
843798 Member Posts: 24,864
edited Jul 31, 2001 11:38PM in Java Runtime Environment (JRE)
Hi

I have some problem executing class file under UNIX.


I have a directory under UNIX,

/home/user1

wherein I have placed a class file say "JavaProg.class"

I execute "java JavaProg" from the above directory
and it generates the desired output.



Now, I have another directory,

/home/user2

wherein I again I have placed the same class file "JavaProg.class"

I execute "java JavaProg" from this second directory
this time and it again generates the desired output.


Problem starts now,

I delete the class file from /home/user2

1. And then I execute the following command trying to
directly execute class file which is available from user1's directory (since user2 class file is deleted)

"java /home/user1/JavaProg" from "/home/user2"
directory. (since I am executing user1's class file
from user2 directory)

On this it says "Can't find the class file".



So I try various other options like.

2. First I set the CLASSPATH as
set $CLASSPATH=.:/home/user1:/opt/java/lib:$CLASSPATH
export CLASSPATH

And I try the following command

"java JavaProg" (This time I dont' write the complete
absolute path since its already defined in the CLASSPATH) I get an error. So I still try the following,



3.

"java /home/user1/JavaProg"

ERROR


4. "java -classpath .:home/user1 JavaProg

ERROr


5. "java -classpath .:home/user1 home/user1/JavaProg

ERROr


6. "java -cp .:home/user1 JavaProg

ERROr


7. "java -cp .:home/user1 home/user1/JavaProg

ERROr


What might be the source of the error. Can anyone
help. Thanks in advance for the help.

Thank,s
JAtin

Comments

  • 843798
    843798 Member Posts: 24,864
    user2 does not have 'execute' permission (i.e. "x") for the home directory of user1.

    check that the file JavaProg.class in /home/user1/ contains the 'execute' permission granted to user2.

    UNIX has this concept of owner/group/world file premission concept.

    HTH.

    Allen Lai
    SUN Developer Technical Support
This discussion has been closed.