Wednesday 20 April 2016

Troubleshoot: Launch RMI project in Intellij

I was absent last week. My grade did a strict trainning of programming java. Fortunately, this time we are not ask to code without IDE, we are allowed to use Intellij to do the project.
The last task to do named RUSH JAVA, it ask to implement a RMI server.

I was ill so I didn't do it. But it seems cool so I try to find some sample about RMI and run a server in  local. My reference file is here : RMI simple tutoriel(in Chinese).
But When I launch the project in Intellij, there is an error like this:

/home/tearsyu/idea-IC-145.597.3/jdk1.8.0_77/bin/java........
java.security.AccessControlException: access denied ("java.net.SocketPermission" "localhost:1234" "listen,resolve")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.security.AccessController.checkPermission(AccessController.java:884)
In according to tutoriel, we shoul add a policy file which declare the permission at runtime, BUT I DIDN'T FIND WHERE SHOULD TO ADD POLICY FILE IN INTELLIJ.

I do add the cmd line "-Djava.security.policy=java.policy Server" to tell the IDE how compiler it, but:
Error: Could not find or load main class Server
Process finished with exit code 1
PS:-Djava.security.policy tells program where the security policy file is, and java.policy is in root dir of project. Content:
grant{ permission java.security.AllPermission;};
I did't find solution for this error, it seems come from an error entry command from IDE.
BUT I FIND  AN OTHER SOLUTION TO RUN IT.
JUST USING COMMAND LINE AT TERMINAL.

Rush/src$javac *.java -d ../out/
Rush/src$java -Djava.security.policy=java.policy -classpath ../out/ Server

Second Terminel:java -classpath ../out/ Client






 

No comments:

Post a Comment