Android Studio - Unrecognized VM option 'MaxPermSize=256m' - java

I just installed Android Studio on Elementary OS 0.3 Freya and run it using the terminal. On my first start-up, however, there's an error message shown:
Gradle 'Test' project refresh failed
Unable to start the daemon process. This problem might be caused by
incorrect configuration of the daemon. For example, an unrecognized
jvm option is used. Please refer to the user guide chapter on the
daemon at http://gradle.org/docs/2.2.1/userguide/gradle_daemon.html
Please read the following process output to find out more:
Unrecognized VM option 'MaxPermSize=256m' Error: Could not create the
Java Virtual Machine. Error: A fatal exception has occurred. Program
will exit.
I read this and tried all the ways to solve it but to no avail. I did notice that his error was somewhat different from mine and thought that might be why I couldn't solve my problem using the ways suggested.
As I executed the .sh file on my terminal, it printed:
Java HotSpot(TM) Server VM warning: ignoring option MaxPermSize=250m;
support was removed in 8.0
(java:5094): Gtk-WARNING **: Unable to locate theme engine in
module_path: "pixmap"
Gtk-Message: Failed to load module "canberra-gtk-module"
I'm not sure whether it's related to the error or not. Please help.

In my case I had a line
org.gradle.jvmargs=-Xmx6408m -XX:MaxPermSize=6408m -XX:+HeapDumpOnOutOfMemoryError
in my gradle.properties file in the project structure.
removing -XX:MaxPermSize=6408m from that file fixed an issue

As it was already said in this thread, Permanent Generation was removed in Java 8, which is used in your case. I think, the easiest solution is to remove parameters associated with Permanent Generation during program execution.
Go to the directory where you have Android Studio. Then go to the bin/ subdirectory. Locate the following files, which contains Java Virtual Machine options:
studio.vmoptions
studio64.vmoptions
Open these files and locate line with MaxPerSize parameter. It should look as follows:
XX:MaxPermSize=256m
Remove this line in both files. I don't know if you are using 32-bit or 64-bit operating system, so you can update both files just in case.
I'm not sure if it will solve your problem, but I would try it in such situation. In my case, with this option and Java 8, I just get the warning, but Android Studio starts anyway. After removing this parameter, Android Studio still starts, but without warning. I'm using Ubuntu 14.04 LTS.
EDIT:
There is another solution for this problem described here: https://stackoverflow.com/a/27913562/1150795.
Go to File > Other Settings > Default Project Structure > JDK location and check the path.
In case of Ubuntu Linux, we can set /usr/lib/jvm/java-7-oracle as default JDK if we are using Oracle JVM. JDK 7 is the safest option for Android.

-XX:MaxPermSize was deprecated in JDK 8, marked as obsolete in JDK 16, and removed in JDK 17. It was superseded by the -XX:MaxMetaspaceSize option.
Change -XX:MaxPermSize to -XX:MaxMetaspaceSize solve my problem.
ref:
https://github.com/expo/expo-cli/issues/4196#issuecomment-1035850918
https://docs.oracle.com/en/java/javase/17/docs/specs/man/java.html#removed-java-options

In my case opening $ANDROID_HOME/tools/lib/monitor-x86_64/monitor.ini and removing
XX:MaxPermSize=256m
from it did the job.

Oh I've solved this problem, I install Oracle JDK 9 when android studio runs on JDK 6 or JDK 7 (if I'm not mistaken).
so I uninstalled Oracle JDK 9, then download and install the JDK 7.

On MacOS the following clause in ./gradlew injects this option:
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\" \"-Xmx1024m\" \"-Xms256m\" \"-XX:MaxPermSize=1024m\""
fi
This file can be edited by hand after the project has been generated.

i had the same issue and i was able to solve it by adding this directly in the terminal
export JAVA_VERSION=1.8
and then try the

Related

IntelliJ IDEA doesn't start on Ubuntu after Change the boot Java runtime

Before, my IntelliJ ran well. But I used java 6 , so my project could not run with gradle.
I switched java to version 8 with the command sudo update-alternatives --config java .
I checked java -version was 1.8.0_312. It's OK, but in IntelliJ, the Java still had version 6. Then, I changed java version in IntelliJ with:
From the main menu, select Help | Find Action or press Ctrl+Shift+A.
Find and select the Choose Boot Java Runtime for the IDE action.
Select the desired runtime and click OK.
And restarted IntelliJ, which could not be opened again. I tried to remove and install it again as well as removing java and installing it again too, but neither did work.
When I run ./idea.sh, I get the following error:
OpenJDK 64-Bit Server VM warning: Archived non-system classes are disabled because the java.system.class.loader property is specified (value = "com.intellij.util.lang.PathClassLoader"). To use archived non-system classes, this property must not be set
Error: LinkageError occurred while loading main class com.intellij.idea.Main
java.lang.ExceptionInInitializerError: null
Now, I'm not even able to "change JRE in intelliJ" as suggested in the comments any more.
I've had the same issue working on windows.
When you check IntelliJ's log (idea.log file) you can find a entry for the change you've made with its 'reset' option.
For me it was: (emphasis is mine)
2022-08-08 09:47:47,906 [ 594730] WARN -
Downloader.RuntimeChooserPaths - Set custom boot runtime to:
C:\Data\Java\jdk-17.0.3.1 in the
C:\Users\username\AppData\Roaming\JetBrains\IntelliJIdea2021.3\idea64.exe.jdk.
On errors, please remove the .jdk file
You find the log files are stored at:
Linux: ~/.cache/JetBrains/IntelliJIdea2020.3/log
Windows: %LOCALAPPDATA%\JetBrains\IntelliJIdea2020.3\log
macOS: ~/Library/Logs/JetBrains/IntelliJIdea2020.3
Converting the comment by the author from May 2 at 4:22 to an answer.
The issue was resolved by changing the JRE path in this file: /.config/JetBrains/IntelliJIdea2022.1/idea.jdk

Installation eclipse: failed to create the java virtual machine [duplicate]

I have formatted my Mac due to some storage issues. Before this, I used Eclipse in a proper way. Now i have installed the JDK
Then, i have installed Java
Until now everything seems to be correct but when I open the Eclipse installer...
What can I do to fix this? I need to work with this the soon as possible.
Thanks
Eclipse on macOS will not start with Java 14 installed, this is being tracked in Eclipse bug 561273.
Installing Java 8 as well does not help. You need to remove the Java 14 install. You could use the Java 13.0.2 release instead.
Eclipse have determined that the root cause of this issue is a change in Java 14 which is described in this bug report JDK-8238225. The fix for this should be in Java 14.0.1
Update: Eclipse runs fine with Oracle Java 14.0.1 so the issue has been fixed.
I also asked this question which was closed, that's why I answer what I have found out: Eclipse will not install on Mac OS Catalina 10.15.4, saying the above error message
Failed to create the Java Virtual Machine.
Deinstalling jdk and install an older one wouldn't help on its own because Eclipse is refusing to install in the first place (as mentioned above). What I have done:
i´ve installed an JDK with boost (you can try several, mine worked with Version 13)
I edited the installer:
Download the dmg file
convert the dmg-file with "hdiutil convert /dev/disk3s1 -format UDRW -o devimage"
mount the converted dmg-file with: "hdiutil attach -owners on devimage.dmg -shadow"
Edit the /Volumes/Eclipse/Eclipse.app/Contents/Info.plist: there is a section which is commented and there you can try the jdk version. You have to give the full path to the java executable, for example:
<string>-vm</string><string>/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/bin/java</string>
Then my eclipse started from the (already) mounted Eclipse image without complaining
I had the same issue myself a while back. In your Eclipsepedia it provided an example of what the eclipse.ini file looks like when your trying to specify a JVM. So just change the eclipse.ini file and then make sure that you have all of the correct documents in that path to match the example.

Eclipse Installation on macOS

I have formatted my Mac due to some storage issues. Before this, I used Eclipse in a proper way. Now i have installed the JDK
Then, i have installed Java
Until now everything seems to be correct but when I open the Eclipse installer...
What can I do to fix this? I need to work with this the soon as possible.
Thanks
Eclipse on macOS will not start with Java 14 installed, this is being tracked in Eclipse bug 561273.
Installing Java 8 as well does not help. You need to remove the Java 14 install. You could use the Java 13.0.2 release instead.
Eclipse have determined that the root cause of this issue is a change in Java 14 which is described in this bug report JDK-8238225. The fix for this should be in Java 14.0.1
Update: Eclipse runs fine with Oracle Java 14.0.1 so the issue has been fixed.
I also asked this question which was closed, that's why I answer what I have found out: Eclipse will not install on Mac OS Catalina 10.15.4, saying the above error message
Failed to create the Java Virtual Machine.
Deinstalling jdk and install an older one wouldn't help on its own because Eclipse is refusing to install in the first place (as mentioned above). What I have done:
i´ve installed an JDK with boost (you can try several, mine worked with Version 13)
I edited the installer:
Download the dmg file
convert the dmg-file with "hdiutil convert /dev/disk3s1 -format UDRW -o devimage"
mount the converted dmg-file with: "hdiutil attach -owners on devimage.dmg -shadow"
Edit the /Volumes/Eclipse/Eclipse.app/Contents/Info.plist: there is a section which is commented and there you can try the jdk version. You have to give the full path to the java executable, for example:
<string>-vm</string><string>/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/bin/java</string>
Then my eclipse started from the (already) mounted Eclipse image without complaining
I had the same issue myself a while back. In your Eclipsepedia it provided an example of what the eclipse.ini file looks like when your trying to specify a JVM. So just change the eclipse.ini file and then make sure that you have all of the correct documents in that path to match the example.

Alert: "Failed to create the Java Virtual Machine" [duplicate]

I have formatted my Mac due to some storage issues. Before this, I used Eclipse in a proper way. Now i have installed the JDK
Then, i have installed Java
Until now everything seems to be correct but when I open the Eclipse installer...
What can I do to fix this? I need to work with this the soon as possible.
Thanks
Eclipse on macOS will not start with Java 14 installed, this is being tracked in Eclipse bug 561273.
Installing Java 8 as well does not help. You need to remove the Java 14 install. You could use the Java 13.0.2 release instead.
Eclipse have determined that the root cause of this issue is a change in Java 14 which is described in this bug report JDK-8238225. The fix for this should be in Java 14.0.1
Update: Eclipse runs fine with Oracle Java 14.0.1 so the issue has been fixed.
I also asked this question which was closed, that's why I answer what I have found out: Eclipse will not install on Mac OS Catalina 10.15.4, saying the above error message
Failed to create the Java Virtual Machine.
Deinstalling jdk and install an older one wouldn't help on its own because Eclipse is refusing to install in the first place (as mentioned above). What I have done:
i´ve installed an JDK with boost (you can try several, mine worked with Version 13)
I edited the installer:
Download the dmg file
convert the dmg-file with "hdiutil convert /dev/disk3s1 -format UDRW -o devimage"
mount the converted dmg-file with: "hdiutil attach -owners on devimage.dmg -shadow"
Edit the /Volumes/Eclipse/Eclipse.app/Contents/Info.plist: there is a section which is commented and there you can try the jdk version. You have to give the full path to the java executable, for example:
<string>-vm</string><string>/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/bin/java</string>
Then my eclipse started from the (already) mounted Eclipse image without complaining
I had the same issue myself a while back. In your Eclipsepedia it provided an example of what the eclipse.ini file looks like when your trying to specify a JVM. So just change the eclipse.ini file and then make sure that you have all of the correct documents in that path to match the example.

How to detect, prevent, and fix java windows registry corruption (i.e. "could not find java.dll")

Problem: java.exe complains about dll
We use a tool that copies-and-renames java.exe to a temp directory, i.e. /path/to/some/dir/java_foo_application.exe. [The tool is 'Yet Another Java Service Wrapper' or YAJSW. It copies-and-renames so that meaningful names show in the windows task manager ]
On some machines, corrupt java entries in the windows registry give this error when running this copied java.exe:
Error opening registry key 'Software\JavaSoft\Java Runtime Environment'
Error: could not find java.dll
Error: could not find Java SE Runtime Environment.
Solved Once Before: Uninstall and reinstall
I've had this problem once before: nd solved it by uninstalling all jdk's -- using windows "add remove programs"-- and reinstalling a newer version of java.
Note that one of the jdk's would not uninstall. I had to download special registry cleaner from microsoft to force uninstallation.
My question: Detect and Prevent?
How can one tell in advance whether a system has corrupt java registry entries?
How to prevent this corruption for the future?
Any other ways to fix this aside from uninstalling and reinstalling the jdk's?
Thanks.
To find out what the real problem, download two jar files:
first and second
remember to set:
wrapper.console.pipestreams = true
Described on this page
The Wrapper log file shows me this trace:
-set state RESTART_START->RUNNING
-Registry key 'Software\JavaSoft\Java Runtime Environment\CurrentVersion'
has value '1.5', but '1.6' is required.
-Error: could not find java.dll
-Error: could not find Java 2 Runtime Environment.
process terminated
Controller State: WAITING -> PROCESS_KILLED
I solve my problem reinstalling System JRE 1.6.
Best regards!
Instead of messing with javaw you could use an executable wrapper to start your application. See for example exe4j or JSmooth.

Categories

Resources