Permanently removing a JAVA_TOOL_OPTIONS environment variable - java

I am trying to run jake on OS X 10.6.4 but get the message Narwhal on Rhino requires Java 1.5 or higher. You have JAVA_TOOL_OPTIONS:.-Xmx512m. This is left over from a previous project where someone told me to set it to get Flash to export without dying.
I have java 1.6 installed. The JAVA_TOOL_OPTIONS seems to be the issue. I removed it using unset JAVA_TOOL_OPTIONS. This worked until I reopened Terminal. The JAVA_TOOL_OPTIONS environment variable comes back.
Any ideas on how I can permanently get rid of this?

You probably set it in the .bashrc or .profile file in your homedirectory, remove it from there and you should be fine when you start a new terminal.

It seems like you have that variable in your environment. All you need to do is to remove it from env:
Just write unset JAVA_TOOL_OPTIONS in your terminal.
Set that line in the ~/.bashrc file to be sure that it will not abuse you next time you run console.

Related

Error after upgrading to JDK 8 on MAC

After upgrading to JDK 8 on Mac, I get the following error when I try and check the java version. Can anyone help me sort it out?
MAC30880443:Versions t821714$ java -version
Error occurred during initialization of VM
java/lang/ClassNotFoundException: error in opening JAR file <Zip file open error> /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/endorsed/jaxb-api-2.2.12.jar
It would appear as if the new JDK got installed, however your JAVA_HOME environmental variable appears to be either unset, or still set to use JDK 7.
To check its current value, you can execute echo $JAVA_HOME
To update the value for your current terminal session, you can execute export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home.
If you want the above snippet to run every time you start a new terminal session, you can enter the following, which will append it to your .profile
echo "export /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home" >> ~/.profile
. ~/.profile
The second line will source that .profile line to load the variables set in it.
Cheers, and happy coding.
Looks like your java PATH is messed up, setting it varies based on OS version so take a look here and make sure it is set properly.
if you are running os 10+ all you have to do is
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile
or if you think you know better than apple and are sure your java_home is in the default location, use:
echo "export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home" >> ~/.bash_profile
then do
source ~/.bash_profile
also make sure java 8 is set in the top of your preferences. (Utilities -> Java Preferences -> General). Click and drag it to the top of the list if it is not there, otherwise you might continue to use the older version of java

JAVA_HOME is not recognized as an internal/external command

I've tried just about everything but it will not recognize it.
I have the latest version of JDK installed, the path is located at "C:\Program Files\Java\jdk1.8.0_25". This is what I'm using for my "variable value" field when I add the new variable "JAVA_HOME"..
I also have a %JAVA_HOME%\bin; in my path variable. I've restarted multiple times, making small changes..
Help me :(
Keep in mind I don't have much of a clue of what I'm doing.. So I could be going about it completely wrong.. Running it in cmd
Change the path value %JAVA_HOME%\bin, instead of set this
C:\Program Files\Java\jdk1.8.0_25\bin
After setting that, open command prompt and check whether you have set JAVA_HOME correctly.
echo %JAVA_HOME%
java
echo %JAVA_HOME% will print the location where java installed and java will show the usage of java.
See here how to set JAVA_HOME

Tomcat 6 JAVA_HOME

I try to set the JAVA_HOME path as my Tomcat server is looking for it. I am trying to set it but it doesn't seem to work and causes an error when I do. I am trying to set the JAVA in the setclasspath.bat using
set JAVA_HOME="C:\Program Files (x86)\Java\jre7"
This is at the start of the setclasspath.bat
set JAVA_HOME="C:\Program Files (x86)\Java\jre7"
if not "%JAVA_HOME%" == "" goto gotJdkHome
if not "%JRE_HOME%" == "" goto gotJreHome
echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
echo At least one of these environment variable is needed to run this program
goto exit
When I set this and run "startup.bat start" it displays
Files was unexpected at this time
Can you help me?
Note: I realise this is already quite an old question, but many of the answers posted here are either incomplete or inaccurate.. Hopefully this will help save a few headaches.
Firstly: Tomcat does not need a JDK to run, it will work just fine with a JRE, as long as it knows it's a JRE.
Secondly, the error from the original question is coming from an issue with syntax of the set JAVA_HOME=... command. Apache themselves could handle it better with stripping and adding " quote marks.
Also, I would highly recommend creating a setenv.bat file in the bin folder. It's absent by default, so if you don't already have one, create it and add your set JAVA_HOME=... or set JRE_HOME=... lines there.
Run with JRE
As per running.txt:
The JRE_HOME variable is used to specify location of a JRE. The
JAVA_HOME variable is used to specify location of a JDK.
Using JAVA_HOME provides access to certain additional startup options
that are not allowed when JRE_HOME is used.
If both JRE_HOME and JAVA_HOME are specified, JRE_HOME is used.
So, to startup this way, you'll need the following:
set "JAVA_HOME="
set "JRE_HOME=C:\Program Files (x86)\Java\jre7"
Clearing the JAVA_HOME variable is a failsafe, but it's not really required. As per the docs, Tomcat will try use the JRE variable first anyway.
Solution for Issue in Question
Take special note the position of the quotation marks. This way keep the entire string together in one variable, without including the quotation marks in the variable content itself.
For example:
set %TEST%="hello"
echo "%TEST%"
Will output ""hello"".
set "%TEST%=hello"
echo "%TEST%"
Will output "hello".
So, the startup batch file script was trying to use ""C:\Program Files (x86)\Java\jre7"", in which the first non-escaped space is between "Program" and "Files".
As already pointed out, removing the quotation marks (in this particular case at least) would work, but it's dangerous to rely on that. Rather play it safe from the start and wrap the variable name and value in quotation marks.
I had the same problem on Windows 7 with the following definition (I put it in a setenv.bat file in the jdk bin folder as specified by tomcat 7's RUNNING.txt.
set JAVA_HOME="C:\Program Files (x86)\Java\jre7"
I just tried removing the double quotes altogether:
set JAVA_HOME=C:\Program Files (x86)\Java\jre7
And tomcat then started.
First, install java and locate the instalation path.
Locate the tomcat installation path and find the startup.bat in \bin
Open startup.bat and add below(example) lines just after setlocal and before rem Guess CATALINA_HOME if not defined
:: JAVA
set JAVA_HOME=D:\thushara_data\Java\jdk1.8.0_73
set PATH=%JAVA_HOME%\bin;%PATH%
Now try to re-run startup.bat
Place the path in quotes:
set JAVA_HOME="C:\Program Files (x86)\Java\jre7"
The error is due to the fact that it's parsing the Files in Program Files as a separate parameter, which SET doesn't expect. Why SET isn't reading it properly I can't say without knowing more about what OS you're using, what command shell you're running Tomcat from, and so on.
If not able to set the variables manually:
to set JAVA_HOME and JRE_HOME
go to advance system setting and click on environment variables
under system variables click
new variable name : JAVA_HOME
variable value : [path of jdk]C:\Program Files\Java\jdk1.8.0_181 and click ok
similarly add JRE_HOME
click new variable name : JRE_HOME
variable value : [path of jre]C:\Program Files\Java\jre1.8.0_181
click Ok > Ok > Ok
You are pointing to a JRE. You need to point to a JDK, which given the location of your JRE might be something like C:\Program Files (x86)\Java\jdk1.6.0_26 or similar. Or, if you only have a JRE installed, you'll need to install a full JDK. Tomcat needs to be able to compile JSPs into .class files, which a JRE can't do.
The reason why your command failed is because it has white spaces between 'Program Files (x86)' and so it starts reading the command from 'Files (x86)'. So instead we put it in between double quotes such as the following.
try this..
set JAVA_HOME="C:\Program Files (x86)\Java\jre7"
Try
https://askubuntu.com/questions/446294/how-to-start-tomcat7-when-catalina-sh-does-not-work
It can give you some insight even though it's not Windows it still looks for those shell scripts except their extensions in Window is .bat not .sh
You Can Also Try This For jre1.8v:
Open cmd In Tomcat Server Folder And Enter Command
set "JAVA_HOME=C:\Program Files (x86)\Java\jre1.8.0_45"
Then Enter Command cd bin
Then To Start Tomcat Server Enter Command startup
To Stop Tomcat Server Enter Command shutdown
If It Fails To Start Although You Can Run Command: cd startup.bat

Why NetBeans' environment variable does not confirm to the system's setting?

I have set JAVA_HOME environment variable in .bashrc like this:
export JAVA_HOME='/opt/Oracle/jdk1.7.0_25'
And I am sure that it's properly set:
$ echo $JAVA_HOME
/opt/Oracle/jdk1.7.0_25
But when I am using NetBeans to start my Google App Engine server, it says:
...
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-7-openjdk-amd64/jre"
Why it is changed?
The env variable is set in any bash window you might open up, but it is not set any other way. It seems you will have to resort to desperate measures to get this environment variable set up, which entails setting the variable from the command line and then starting NetBeans from the command line. I can't think of any other way.

Script to Change JAVA_HOME System Variable in Windows

I do most of my work against JDK 1.5 - but occasionally I have to change to 1.6. it is a bit painful to have to manually go and change my 'JAVA_HOME' system variable whenever I need to work on a project specific to one or the other (and no, Eclipse doesn't play well in these scenarios - trust me...I've tried.)
I'm looking for a registry script or windows shell script or for that matter any means by which I can "toggle" this system variable with something that is easy to run.
I've messed with the 'set' command, but that only sets the variable for that particular command instance - not globally.
Thanks in advance.
EDIT #1:
Points of advise:
Use the JAVA_HOME variable in your path variable as well, that way you only have to change the JAVA_HOME (which is used in many projects anyways [maven, ant, etc])
Write the command into a couple batch scripts for easy use
When you make the change the windows command session will not reflect it right away. You must close and reopen it.
You could use setx for that purpose
Like so:
setx /M JAVA_HOME "C:\Program Files (x86)\Java\jdk1.6.0_17"

Categories

Resources