Search code examples
javabashroot

How to run java command as root?


I get the infamous error "Could not find or load main class..." when I am trying to run java command as root.

I tried this solution without any success.

which java returns /usr/bin/java so I tried appending at ˜/.bashrc

export PATH=$PATH:/usr/bin/java

or

export PATH=$PATH:/usr/bin, again... without success.

ps: I want to run as root because I've created a simple server using sockets and I want to ping it with an android app. The problem is that I am getting permission denied.


Solution

  • Maybe this could help:

    sudo java -cp $CLASSPATH com.blubber.Bla