解决Warning Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
系统:Ubuntu 16.04 LTS
环境:vscode+java extension pack打开了一个gradle的java项目;另外,用一个terminal启动了groovysh
报错:
groovysh报错 java.util.prefs.FileSystemPreferences syncWorld
警告: Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
参考资料[1]:https://stackoverflow.com/questions/2027566/java-util-prefs-throwing-backingstoreexception-why
解决:
根据[1]中“If two JVMs attempt to lock the file at the same then this is what you'll see.”
打开任务管理器,看到两个java进程,一个是vscode java extension 运行的 eclipse jdt 所启动的jvm(jvm1),另一个是groovysh所启动的jvm(jvm2)
所以,是因为jvm1进程已经获取lock了,导致jvm2无法获取lock而报错
关闭vscode的java项目之后,groovysh不再报错