Android Studio can't open (port.lock access denied) - java

When I open the Android Studio it gives the following error:
java.io.FileNotFoundException: C:\Users\HP\.AndroidStudio2.2\config\port.lock (Access is denied)
The javac path is correct
and the file has anyone can access (port.lock)
This is the full error message which I was getting:
java.io.FileNotFoundException: C:\Users\HP\.AndroidStudio2.2\config\port.lock (Access is denied)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at com.intellij.idea.SocketLock.underLocks(SocketLock.java:186)
at com.intellij.idea.SocketLock.lock(SocketLock.java:128)
at com.intellij.idea.StartupUtil.lockSystemFolders(StartupUtil.java:318)
at com.intellij.idea.StartupUtil.prepareAndStart(StartupUtil.java:140)
at com.intellij.idea.MainImpl.start(MainImpl.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.ide.plugins.PluginManager$2.run(PluginManager.java:93)
at java.lang.Thread.run(Thread.java:745)

In my case i have to apply tick to hidden icons in also sub folders of C:\Users\HP and again apply tick to show hidden icons.Now works fine

In my case, Java was installed under a different admin account on the default path, while I was trying to use Java under my admin account.
After a new installation of Java under my own admin account, the problem got solved.

Try to to delete everything under C:\Users\Administrator.gradle\caches. There is a cache.properties.lock that is holding a global lock which is preventing you from running your script. Using MacOS you will find it in your home directory ~/.gradle/caches
It Works for me.
I hope It Should fix the problem.

I had the same problem and in my case the problem was with permissions for the config folder - for some reason the config folder was read only.
I changed the permissions and it was ok.

My Android Studio was not opening and throwing the same error as above.
I went and deleted the below folder -
.AndroidStudio3.5 (It should be in C:/users/[insert current user]/.androidstudio3.5)
Delete the whole folder and try running the studio again.

Related

How do I resolve fileNotFoundException in Java using Intellij

My project on Intellij does not run my project any more, it keeps throwing some compilation errors.
I have tried Rebuilding, Building and also Invalidate Cache/Restarted but I didn't work I also checked out this link below, but it didn't work for me:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206885455-java-Cannot-find-JDK-1-7-for-module
I keep getting this error
java.io.FileNotFoundException: /home/byteworks/Documents/Projects/ics-assessment-api/ics-assessment-controller/out/production/resources/customers-template/AGENCY_CUSTOMER_MASTERLIST_TAXPAYER v1.0.xlsx (Permission denied)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
at com.intellij.openapi.util.io.FileUtil.openOutputStream(FileUtil.java:492)
at com.intellij.openapi.util.io.FileUtil.performCopy(FileUtil.java:452)
at com.intellij.openapi.util.io.FileUtil.copyContent(FileUtil.java:447)
at org.jetbrains.jps.incremental.FSOperations.copy(FSOperations.java:437)
at org.jetbrains.jps.gradle.compiler.GradleResourceFileProcessor.copyFile(GradleResourceFileProcessor.java:68)
at org.jetbrains.jps.gradle.compiler.GradleResourcesBuilder.build(GradleResourcesBuilder.java:101)
at org.jetbrains.jps.gradle.compiler.GradleResourcesBuilder.build(GradleResourcesBuilder.java:28)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTarget(IncProjectBuilder.java:1037)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1018)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1074)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:968)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:797)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:375)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:178)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:135)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:229)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Please perform full project rebuild (Build | Rebuild Project)```
As someone else has said it is saying permission denied, Has the folder or file been moved or altered by some form of protection / anti virus?
The error appears to be where it is trying to copy the file from
/home/byteworks/Documents/Projects/ics-assessment-api/ics-assessment-controller/out/production/resources/customers-template/AGENCY_CUSTOMER_MASTERLIST_TAXPAYER v1.0.xlsx
Is that still the path where that xlsx is ? also shouldnt it be xslx.
Could that be the problem you have a typo in the filename in the build.gradle copy command?
looks like you are on some form of linux computer as you have a /home/byteworks folder, are you the user byteworks? if not do you have permission to access the byteworks folder as Users can restrict access to their Documents folder. check the file owner and permissions if you do an ls -la in the folder then you can see the flags,
_rwxrwxrwx - The flags are
_ = the SetUUID/SetGroup/Sticky flag
rwx - owner permissions Read Write Execute (Execute is also ls view permission on folders)
rwx - group permissions
rwx - other permissions - if the last one is ___ that means anyone who isn't the owner doesn't have permission to access the file.

How to get around the (Access is denied) to a folder that your java program is saving a file to?

I was wondering if someone could help me find a good resource to help me fix this issue. I'm trying to create/save a batch file in the startups folder. Here's the general path: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\startup_PMA_popup_check.bat
I've read a lot of things saying that I should simply elevate the privileges of my java program.
I read that if I was to make my jar file a windows executable, then the rights of the program are automatically elevated to admin privileges.
What you're seeing below is my jar turned into an exe and run. The error I got was the same error as the one I got from running my jar. I no longer think that the problem is simply giving my program admin privilege.
I performed a test outside of my program by going to this path and attempting to move a file into the folder. Assuming I'd have no issue "since I am root already", I went ahead expecting to get no prompts. What I got was a popup saying that I needed to confirm that I was Admin & to confirm that I wanted to put the batch file in the folder.
My question is how should I make my java program issue this prompt to the user or something so my program can continue & not crash like shown below??:
Exception in thread "main" java.io.FileNotFoundException:
C:\ProgramData\Microsoft\Windows\Start
Menu\Programs\StartUp\startup_PMA_popup_check.bat (Access is denied)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(Unknown Source)
at java.io.FileOutputStream.(Unknown Source)
at java.io.FileOutputStream.(Unknown Source)
at java.io.PrintWriter.(Unknown Source)
at java.io.PrintWriter.(Unknown Source)
at prioritymanagementassistant.Background.createBatchFile(Background.java:106)
at prioritymanagementassistant.Main.main(Main.java:930)
Thank You for your time,

java.io.FileNotFoundException: ~/play-2.1.1/framework/sbt/boot/update.log (No such file or directory)

I wrote a Puppet to install Play 2.1.1 on Virtual Machine running CentOS 6.2.
The Puppet executed the following two commands:
/usr/bin/wget http://downloads.typesafe.com/play/2.1.1/play-2.1.1.zip
/usr/bin/unzip play-2.1.1.zip
When I run play command inside the package, it shows the following error message:
java.io.FileNotFoundException: ~/play-2.1.1/framework/sbt/boot/update.log (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:209)
at java.io.FileOutputStream.<init>(FileOutputStream.java:160)
at java.io.FileWriter.<init>(FileWriter.java:90)
at xsbt.boot.Update.<init>(Checks.java:51)
at xsbt.boot.Launch.update(Launch.scala:275)
at xsbt.boot.Launch$$anonfun$jnaLoader$1.apply(Launch.scala:120)
at scala.Option.getOrElse(Option.scala:108)
at xsbt.boot.Launch.jnaLoader$2f324eef(Launch.scala:115)
at xsbt.boot.Launch.<init>(Launch.scala:94)
at xsbt.boot.Launcher$.apply(Launch.scala:290)
at xsbt.boot.Launch$.apply(Launch.scala:16)
at xsbt.boot.Boot$.runImpl(Boot.scala:31)
at xsbt.boot.Boot$.main(Boot.scala:20)
at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.io.FileNotFoundException: ~/play-2.1.1/framework/sbt/boot/update.log (No such file or directory)
I didn't change a single line of code in the play-2.1.1 directory. I googled around for the error message, but did not find any useful answer. Could anyone point out what is the problem?
If the file does not exist and cannot be created,FileOutputStream will raise a FileNotFoundException (yes, this seems weird, but see the javadoc).
This error probably means that the user that started play does not have the proper permissions to create ~/play-2.1.1/framework/sbt/boot/update.log or its parent directories.

Creating Lock file in Programs Folder causes exception

I recently decided to use an official installer for my Java application.
The application installs its self in the appropriate folder under the Programs Files.
Inside the bin folder where the jar for my application sits, I have a h2.db file which contains a bunch of information that is read by the application.
When I try running the application in the installed location I get an exception:
org.h2.jdbc.JdbcSQLException: IO Exception: "java.io.FileNotFoundException: C:\Program Files (x86)\Aurora Game Hub\bin\AuroraDB.lock.db (Access is denied)"; "C:/Program Files (x86)/Aurora Game Hub/bin/AuroraDB.lock.db" [90031-167]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:158)
at org.h2.message.DbException.convertIOException(DbException.java:315)
at org.h2.store.fs.FilePathDisk.newOutputStream(FilePathDisk.java:265)
at org.h2.store.fs.FileUtils.newOutputStream(FileUtils.java:223)
at org.h2.store.FileLock.save(FileLock.java:197)
at org.h2.store.FileLock.lockFile(FileLock.java:333)
at org.h2.store.FileLock.lock(FileLock.java:128)
at org.h2.engine.Database.open(Database.java:542)
at org.h2.engine.Database.openDatabase(Database.java:222)
at org.h2.engine.Database.<init>(Database.java:217)
at org.h2.engine.Engine.openSession(Engine.java:56)
at org.h2.engine.Engine.openSession(Engine.java:159)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:138)
at org.h2.engine.Engine.createSession(Engine.java:121)
at org.h2.engine.Engine.createSession(Engine.java:28)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:305)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:110)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94)
at org.h2.Driver.connect(Driver.java:72)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at aurora.engine.V1.Logic.ASimpleDB.searchAprox(ASimpleDB.java:828)
at aurora.V1.core.GameSearch.searchGame(GameSearch.java:249)
at aurora.V1.core.GameSearch.run(GameSearch.java:346)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\Program Files (x86)\Aurora Game Hub\bin\AuroraDB.lock.db (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at org.h2.store.fs.FilePathDisk.newOutputStream(FilePathDisk.java:257)
... 22 more
It works fine when its not in the Program Files location, as I would have noticed this while developing.
i'm thinking it has something to do with permissions and the lock file not able to be created or something. Is there a way to give/ask explicit permission to create the lock file or can I tell H2 to just not create the lock file?
We've thought about having the static database placed somewhere other then the install location, but since this has to run on Mac and PC and the way the installer is set up it would make things more complicated.
Any help would be very much appreciated.
It seems there are no access rights to write to this directory. You need to store the database file in a directory where you do have access rights.
For H2, if you use the database URL jdbc:h2:~/data/db, the database is stored relative to the current user home directory. Another alternative is to use an absolute path, for example jdbc:h2:c:/dir/to/db/file
This is caused by improved security in windows. You can write only when you have elevated privilages. For example if you start program as 'run as administrator', then it may able to write to Program Files area. Then it is not a good idea- see: Bypass Windows permission restrictions on program files folder
You should use folder pointed by 'ProgramData' variable. or good old user.home area
On Mac OS X, you can use the known subdirectories of user.home cited here.
Java Web Start with suitable permissions may be an alternative, although I haven't tried it.

java.io.FileNotFoundException: C:\opt\apache-tomcat-6.0.36-ins2\logs\localhost.2013-02-11.log (Access is denied)

C:\opt\apache-tomcat-6.0.36-ins2 is where my tomcat instance located.
When I start up the tomcat instance today, I received the following error immediately (on the very first line). I have been able to start the tomcat up without this type of error until today. May I ask if there's any fix to this?
java.io.FileNotFoundException: C:\opt\apache-tomcat-6.0.36-ins2\logs\localhost.2013-02-11.log (Access is denied)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.(FileOutputStream.java:192)
at org.apache.juli.FileHandler.openWriter(FileHandler.java:374)
at org.apache.juli.FileHandler.(FileHandler.java:99)
at org.apache.juli.FileHandler.(FileHandler.java:90)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:515)
at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:460)
at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:286)
at java.util.logging.LogManager$2.run(LogManager.java:267)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.logging.LogManager.readPrimordialConfiguration(LogManager.java:265)
at java.util.logging.LogManager.getLogManager(LogManager.java:248)
at java.util.logging.Logger.(Logger.java:225)
at java.util.logging.LogManager$RootLogger.(LogManager.java:1094)
at java.util.logging.LogManager$RootLogger.(LogManager.java:1091)
at java.util.logging.LogManager$1.run(LogManager.java:180)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.logging.LogManager.(LogManager.java:157)
at java.util.logging.Logger.getLogger(Logger.java:287)
at org.apache.juli.logging.DirectJDKLog.(DirectJDKLog.java:71)
at org.apache.juli.logging.DirectJDKLog.getInstance(DirectJDKLog.java:178)
at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:171)
at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:243)
at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:298)
at org.apache.catalina.startup.Bootstrap.(Bootstrap.java:55)
In windows, having a log file open in an editor would prevent other processes from writing into it. So, close any editors having the log file open.
Sometimes also the permissions of folders get mismatched - in that case emptying the logs folder / moving existing logs elsewhere should fix it.
Even I Got the same exception while starting tomcat6, in my case this problem is because of the permission that set to the log folder, finally this solved by setting read write permission on the log folder to the current user.
Now Tomcat6 is started successfully :)

Categories

Resources