Setting up Tomcat through the Cmd line - java

I am presently trying to get tomcat to run on my computer for a servlet application. If i click the startup shell then the cmd line pops up then disappears. i tried to set up the Environmental variable with the lineJAVA_HOME=c:\Program Files\Java\JDK1.8.0_45 and JRE_HOME=c:\Program Files\Java\JDK1.8.0_45 and anytime i try to run startup i get the error:
The JRE_HOME environment variable is not defined correctly
This environment variable is needed to run the program
I have read through the tutorials and do not understand them, so if im missing something obvious please explain it simply

JRE_HOME is jre's path. Under \Java folder, you'll see jre7 probably. Copy its path to JRE_HOME section in environment variables.

Related

Apache Ant installation Windows 7

When I do ant -version on command line, it says not recognized. Any ideas on how to fix? I'm trying to make a build.xml for a Java project.
You have set JAVA_HOME and ANT_HOME as User environment variable. The path you set is in System environment variable.
You can fix it by many ways. One way will be to define JAVA_HOME and ANT_HOME in System Environment setting.
Another way will be to modify PATH variable in user environment section.
Make sure your JAVA_HOME and ANT_HOME and PATH are set correctly.
ANT_HOME is used by the launcher script for finding the libraries.
JAVA_HOME is used by the launcher for finding the JDK/JRE to use. (JDK is recommended as some tasks require the java tools.) If not set, the launcher tries to find one via the %PATH% environment variable.
PATH is set for user convenience. With that set you can just start ant instead of always typing the/complete/path/to/your/ant/installation/bin/ant.
Set these variables correctly and open a new cmd window (don't use old cmd window, please open new window)
type echo %PATH% , should show java and ant
Open command window(cmd) and type
java -version
If this shows java version , this means java is in your path and working.
finally type ant -version

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

ANT Installation - Receiving "Access is denied." Error

I have copied over the apache ant directory in to my D:\ drive on my PC. Running Windows XP, by the way. I have set the following environment variables below...
ANT_HOME = D:\apache-ant-1.8.2
JAVA_HOME = C:\Program Files\Java\jdk1.6.0_43
%ANT_HOME%\bin added to Path variable
When I run ant -version or ant on the console, I receive the following error
Access is denied.
So now I am at a stand still. I have tried copying over the ant directory to the C:\ drive, changing the corresponding variable, and I get the same error. I have tried adding JAVA_HOME to my Path variable, and I still get the same error. I have tried switching to the D:\ drive, and again, the same error.
Please help!
This problem may relate to the JAVA_HOME variable. Make sure set ANT_HOME, PATH, JAVA_HOME env variables and try again.

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

How to start jboss 7.1.1 server and deploy project in jboss 7.1.1

I use JBoss 7 server so I downloaded JBoss 7.1.1 version and unzip this zip file.
Then I go to bin folder and double click on standalone.bat but new cmd window open and close within 2 -3 sec.
If I run it using cmd, I get:
E:\jboss-as-7.1.1.Final\bin>standalone.bat
Calling "E:\jboss-as-7.1.1.Final\bin\standalone.conf.bat"
then it stops.
So the JBoss server does not start.
How can I run JBoss server and deploy projects in it on Window 7?
Give JAVA_HOME environment variable in your System Properties Environment Variables likes this;
C:\Program Files\Java\jdk1.7
Give JBOSS_HOME environment variable in your System Properties Environment Variables likes this;
E:\jboss-as-7.1.1.Final
Could you try by putting your Java outside "Program Files". Sometimes commands fail because of the space in the path. Like your JAVA_HOME path is set to "C:\Program Files\Java" and hence it might be failing.
Please try to put Java folder directly under C:\ and set the JAVA_HOME variable (without bin) and also JBOSS_HOME variable in similar way (without bin).
Have you tried right clicking "cmd" and "Run as administrator"? Then cd to the folder and run it there...
or right click the bat file and "Run as administrator"?
I think usually starting server required administrator rights in Windows 7.
It solved. Changing the java_home to c:\java\jdk1.6.0_23 and setting java_home environment variable to that route
You need to add both JBOSS_HOME AND JAVA_HOME as explained above.

Categories

Resources