Starting Tomcat 7 from command line (Windows) - java

I'm wondering if there is a way to start Tomcat7 server from the cmd line?
I researched this and all signs seem to be pointing to running a startup.bat/shutdown.bat file that should be present in the bin folder of my Tomcat directory.
However, my bin folder doesn't contain these files.
It only contains:
- bootstrap.jar
- Tomcat7
- Tomcat7w
- tomcat-juli.jar
I did a bit more searching for these .bat files and stumbled across shortcuts called 'Configure Tomcat' and 'Modify Tomcat'. The 'Configure Tomcat' just gives you an option to start/stop the server by clicking a button and the 'Monitor Tomcat' didn't appear to do anything.
Is this normal? Or did something go wrong with my download?
I feel like there should definitely be a way to start the server in the cmd line.
Thanks in advance.
UPDATE: I uninstalled and reinstalled Tomcat7 and there were still no startup/shutdown.bat files present but however now I can start and stop the server from the system tray beside the clock. Hopefully this will help me..

The Tomcat EXE/installer package for some reason does not include the startup scripts found in the bin/ directory. Instead, grab the ZIP distribution and copy the files from the bin/ directory into your existing installation.

Related

AEM jar not starting

I have an AEM jar file AEM_6.5_Quickstart. I am trying to get it running but facing issues.
First thing is my jar is not identified as normal on my system like other jars, as you can see there is no icon associated with my jar file.
Second is when i double click on it to run it i get the below prompt to choose the program to run it with, which ideally should not appear. I was getting errors when i was running maven command to generate project using zulu jdk so i had installed jdk from oracle website, now that is removed from my system and when i double click on jar file i still get the option to run it using oracle jdk
Third problem which i am facing is that when i run the jar using zulu x64 Architecture as in above image it starts the jar but i get the below error when i go to localhost:4502
i google searched for solutions and found that indexing might be the problem so i deleted the file at crx-quickstart/repository/index after stopping the jar. When i restart it it gets stuck and doesnt start for some reason as in below picture, the progress bar doesnt move even though i waited for hours. I also made sure that sling authenticator service was running.
This is the output in case it helps for the java version being used and the path is setup as C:\Program Files\Zulu\zulu-11\bin. I am unable to fix this issue, any help is much appreciated.
First, delete the whole crx-quickstart directory (since this is a local environment being set up for the first time), and this way you will have a clean start. After that, maybe the .jar extension is missing from the filename, please add it. Finally, it is easier to use a .bat or .sh script (you can customize parameters and runmodes for AEM). But for a first run, quick setup with the default sample content, just try java -jar AEM_6.5_Quickstart.jar
It seems like windows messed up with your java versions, you can go and fix your windows JDK references from the registry, you can do that by pressing win + R then type "regedit", once open look for the next value:
"HKEY_CLASSES_ROOT\jarfile\shell\open\command" then open the "default" value and check that your path is correct, mine for example is :
"C:\Program Files\Java\jdk1.8.0_202\bin\javaw.exe" -jar "%1" %*
use mine as reference only change the first part between quotes for your path to the JDK.
Usually that should fix it, but some times there are some other registry references that ruin your jar files association, if you can open PowerShell/cmd or bash terminal type java -version and get the proper version of your Java installation, another workaround can be opening terminal, navigate in terminal where your jar lives and then type
java -jar yourJarFile.jar

NetBeans 8.0.2 fails to start Tomcat because of missing catalina.bat

I just finished setting up the prelimanary steps for a Java Web project on NetBeans. I installed NetBeans and created a network drive using Samba on my home Ubuntu Server, which has Tomcat7. When I try to run the example Hello World project, i get the following error:
Starting of Tomcat failed, the Z:\usr\share\tomcat7\bin\catalina.bat startup script is missing.
C:\Users\\Documents\NetBeansProjects\WebApplication1\nbproject\build-impl.xml:1150: Starting of Tomcat failed, the Z:\usr\share\tomcat7\bin\catalina.bat startup script is missing.
BUILD FAILED (total time: 3 seconds)
I checked the directory its is referencing and there is a catalina.sh file but no .bat file. Anyone know hints to get this file or how to get NetBeans to run the .sh file instead?
Download the appropiate zip file from https://tomcat.apache.org/. I use Tomcat 8.0.33 and I download zip file from the zip link in the Binary Distributions subsection of the 8.0.3 section download zip file.
Open the zip file (you don't need uncompress it), go to bin folder, copy the catalina.bat file.
Go to Apache Tomcat bin folder in you machine and paste the catalina.bat file.
Go to you NetBeans, click on Services tag (window -> services), left click in ApacheTomcat, click Start option
If must copy other files like setclasspath.bat, go to step 2.
If you are using Windows, Netbeans need the .bat file, not the .sh file.
catalina.bat file is distributed with the Tomcat binary distribution.
It's not in your path means either you have mingled with the files or you have downloaded wrong distribution (eg: source distribution).
So download a fresh copy of tomcat from here, set the path correctly and try again.
For some reason that I don't know, if you download the zip version of Tomcat, the .bats are there. It's not the same for the installer version though. (I am on Windows BTW, I don't know what happens on Linux.)
The Problem is happening when you are using the installer, use the distribution copy. it worked for me

Error running Tomcat 7.0.34: Can't find catalina.jar

I have a Java web application that I have been working on 6 months ago and when I last worked on it, it would run perfectly. When I ran it again 6 months later I got this error "Can't find catalina.jar". I'm using IntelliJ 13.0 and tomcat 7.0.34.
Can anybody help me with this problem?
I had the same problem and solved it like this:
The method is to chose right Tomcat Home and Tomcat base directory in the wizard Run/Debug Configuration -> Server -> Configure...
Catalina.jar should already be present in tomcat/lib directory.
Is your tomcat home set up correctly, and is the jar there.
Also ensure that the user trying to access the lib directory and Catalina.jar etc.. has access to do so (Unix).
This problem may have occurred because Tomcat was loaded into the Program Files directory. Intellij IDEA cannot read files from Tomcat/lib inside program files. It can be decide: to run the IDEA with administrator rights or download Tomcat to another directory.
I have already fixed this problem,you need to correct the Tomcat Home's path.
My problem is that I renamed the file of apache-tomcat-8.5.9 to Tomcat,then the Idea could not distinguish the version.

Setting javacc to work with command prompt

I've been trying to set up javacc but am having problems. When I type javacc adder.jj (in the directory where adder.jj is) I am getting "'javacc' is not recognized as an internal or external command, operable program or batch file".
To my understanding I have to go to environmental variables, TEMP and change PATH to have C:\javacc-6.0\bin; added to the start. (I extracted the javacc zip to C:). I have tried this and restarted my computer with no luck. I also tried adding C:\javacc-6.0\bin\lib but again no luck. I did this when I installed java to get cmd to recognise javac and it worked!
This is probably trivial but I just can't get it to work!
Thank you
Henry
In the version 6.0 the bin directory is missing the scripts which run javacc. That is why you are getting the error from the windows command prompt.
What you have is a jar file javacc.jar located in the lib directory. All you need is to add that jar file to your classpath and run the java.exe and pass the main class which runs javacc, the later happens to be named javacc too, so to run javacc just proceed like this:
cmd> java -cp C:\javacc-6.0\bin\lib\javacc.jar javacc
In the latest version they seem to have forgotten to add the scripts in the bin folder of the package. You can download version 5.0, it containes all the script files you need, among others a file with the name javacc.bat, this is the one the window commad prompt is looking for and not finding in your case.
Of course, you can just copy those scripts from the 5.0 version to the bin directory of the 6.0 version, they will also work. and since you already have set the path to contain C:\javacc-6.0\bin then you can run it like you have tried before, without closing the command prompt window or even restarting your whole computer!
Edit - new links
The links above are unfortunately no longer valid, luckily the content has been moved to github. here the new links:
Project url: https://javacc.org/
Project url on github: https://javacc.github.io/javacc/
Earlier versions: https://github.com/javacc/javacc/branches/
Solution
Download version 5.0, copy the files that come in the bin folder, except the lib folder (they are .bat files)
Paste those files in the same location, but in version 6.0 and resolved issue.
The error is that they did not add the executables in the bin folder.
open cmd
cd to the directory where the javacc (calculator_2.jj) file loacted
type in the cmd java -cp D:\S2018\CS661\javacc-6.0\javacc-6.0\bin\lib\javacc.jar javacc calculator_2.jj

Unknown version of Tomcat was specified in Eclipse

I want to add latest tomcat-7.0.42 in my eclipse. Probably eclipse tomcat server adapter 7 only supports tomcat version upto 7.0.12 ..
So please help me how can I configure my eclipse with tomcat-7.0.42
You are specifying tomcat source directory.
You need to specify tomcat binary installation root directory, also known as CATALINA_HOME.
Usually, this is where you untar apache-tomcat-7.0.42.tar.gz file.
This happened to me because Tomcat was still in the process of downloading (Download and Install). The message disappeared after a few minutes.
The eclipse window should really have some type of progress indicator showing download status.
To recognise your Tomcat installation folder, Eclipse is scanning for the following files:
conf/catalina.policy
conf/server.xml
conf/web.xml
conf/context.xml
conf/tomcat-users.xml
conf/catalina.policy
conf/catalina.properties
lib/catalina.jar
so make sure you're pointing to the right place and have the right read permissions.
E.g.
OS X (if installed via brew), it's: /usr/local/opt/tomcat/libexec
Linux/Ubuntu: see: Tomcat and Eclipse Integration Error
For LINUX the installation directory for Tomcat 7 is:
/usr/share/tomcat7
Please use this configuration.
More here:
http://gridlab.dimes.unical.it/lackovic/eclipse-tomcat-ubuntu-jersey/
I got the same error and resolved it by giving enough permissions to the folder. I gave full permissions by (you can try limited permissions which is enough for eclipse to run tomcat)
sudo chmod -R 777 apache-tomcat-8.5.33/
FYI, I encountered this error on my mac, but I think it should be same for ubuntu system too.
I know this is and oldie but i had this issue recently with the latest versions of Tomcat and Eclipse on Windows 10.
It was a permissions issue. All i had to do was navigate to the Tomcat install directory and open the folder. I was prompted to access the folder as an Administrator.
After this the versions were recognised by Eclipse and I could add the new runtime.
I am on MacOS and installed tomcat using homebrew, Following path fixed my problem
/usr/local/Cellar/tomcat/9.0.14/libexec
Probably, you are trying to point the tomcat directory having the source folder. Please download the tomcat binary version from here .For Linux environments, there you can find .zip and .tar.gz files under core section. Please download and extract them. after that, if you point this extracted directory, eclipse will be able to identify the tomcat version. Eclipse was not able to find the version of tomcat, since the directory you pointed out didn't contain the conf folder. Hope this helps!
As soon as you provide the directory where Tomcat needs to be installed and click ok you can notice download and installation starts in the progress tab of Eclipse.
Let the process complete.The error will automatically disappear.
Note: It is not mandatory to name your folder CATALINA_HOME. I have tested this with windows. Cannot assert the same for Linux but IMO same rule should apply.
Just in case...
Apache Tomcat 8.5.X is not compatible with Apache Tomcat 8.0 server selection in eclipse. And it gives this error.
Go to "Window -> preferences -> Server -> Runtime Environments"
Remove the existing servers they might not have downloaded completely.
Add new Server
For Windows Users,
Use the Tomcat Service Installer from the Apache tomcat downloads page. You will get a .exe file. which Installs the service for windows. It will usually install Apache tomcat at "C:\Program Files\Apache Software Foundation\Tomcat 8.0" and its easily recognized in eclipse.
Having installed tomcat with brew the solution for me was:
sudo chmod -R 777 /usr/local/Cellar/tomcat/<your_version>
In my case I used wrong directory, the right one is lib exec and my path:
/usr/local/Cellar/tomcat#7/7.0.96/libexec
You are pointing to the source directory. You can run a build by running ant from that same directory, then add '\output\build' to the end of the installation directory path.
It may be due to the access of the tomcat installation path(C:\Program Files\Apache Software Foundation\Tomcat 9.0) wasn't available with the current user.
Since this is evidently happening on Linux, this would be because your dev user might not have read access to Tomcat's installation directory. That's because Tomcat's installation directory (let's say it is pointed to by CATALINA_HOME) is owned by tomcat:tomcat while your dev user is something that's neither tomcat nor one that belongs to the tomcat group. Therefore Eclipse fails to read ${CATALINA_HOME}/conf/catalina.policy.
The following should fix the permission issue:
sudo find ${CATALINA_HOME} -type d -exec chmod o+rx {} \;
Why do we need the execute bits? Because to traverse a directory and reach its descendants, you need execute permissions. In your case, if CATALINA_HOME isn't yet set, replace the actual installation directory (/opt/tomcat/apache-tomcat-<version> maybe?) in the above.
For Windows
Just open the (tomcat xx.x) folder once and check if you can see all other root folders while selecting folder.
Sometimes windows wont give access to this folder

Categories