Local Tomcat in IntelliJ - Cannot run program catalina.bat - java

I have created Local Tomcat (8.5.15) run configuration in IntelliJ IDEA (2019.2). I am running Windows 10. When I try to run the configuration, I get error:
Error running 'Local Tomcat': Cannot run program "C:\apache-tomcat-8.5.15\bin\catalina.bat" (in directory "C:\apache-tomcat-8.5.15\bin"): CreateProcess error=2, The system cannot find the file specified
Environment variables are set:
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_221
CATALINA_HOME=C:\apache-tomcat-8.5.15
%JAVA_HOME%\bin and %CATALINA_HOME%\bin added to PATH
In Run/Debug Configurations -> Startup/Connection, Startup script and Shutdown script are set to valid paths:
C:\apache-tomcat-8.5.15\bin\catalina.bat run
C:\apache-tomcat-8.5.15\bin\catalina.bat stop
When run from terminal, Tomcat starts correctly.
I have replaced catalina.bat with some mock script (just echo sth) as Startup script in run configuration, got the same error.
No other logs are visible in IntelliJ.

Changing system environment variable ComSpec does the job.
In my case I had two cmd.exe configured 32 bit and 64.
I removed 32 bit and it started working. Look out as after edit - there might be ; that also need to be removed.

Related

Can't open Tomcat startup

I can't seem to open up the Tomcat console despite having just been able to successfully do so. When I click on the "startup" Windows Batch File, the console opens then closes itself immediately afterwards. I've read that it has something to do with setting up the environment variables / paths correctly but I've looked at it and it seems fine; you can check the picture out.
NOTE: Over the course of step 6, the javac command did not work for me. To fix I added a second "C:\Program Files..jdk1.8.0_131\bin" into the Path variable (as you can see in the picture. This enabled me to use the javac command but I have no idea why it didn't detect the JAVA_HOME.
Trying to run startup via cmd console outputs the message: D:\myProject\tomcat\bin>startup
The JRE_HOME environment variable is not defined correctly
This environment variable is needed to run this program
I'm still a beginner with server management so I've been following this tutorial: https://www.ntu.edu.sg/home/ehchua/programming/howto/Tomcat_HowTo.html. I'm at the end of step 6c) where it tells me I should restart the server after compiling an servlet and creating an xml. But lo and behold, it won't open again after quitting...
You must not point JAVA_HOME to bin directory. Just point it to jdk directory, and add a %JAVA_HOME%\bin to your path variable.

Problems installing Jasperserver with Powershell. ANT can't see Java

I'm trying to install Jasperserver onto a Windows VM with Powershell.
I can install Java just fine, but some subsequent bat files that get run are complaining they can't find environment variables such as JAVA_HOME. I can see they exist however.
I add the environment variables:
[Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Java\jdk1.8.0_91", "Machine")
[Environment]::SetEnvironmentVariable("JRE_HOME", "C:\Program Files\Java\jre1.8.0_91", "Machine")
[Environment]::SetEnvironmentVariable("CLASSPATH", "C:\Program Files\Java\jdk1.8.0_91\jre1.8.0_91\lib\rt.jar", "Machine")
And also the path variable. Going into System -> Advanced System Settings -> Environment variables I can see they are there, so I assume it's not just setting the powershell session.
When I try to run ANT (though a build in batch)
cd C:\Jaspersoft\jasperreports-server-6.2.0\apache-tomcat\bin
$arguments = '/c service.bat install'
Start-Process cmd -Wait -PassThru -ArgumentList $arguments
it gives me this error:
> WARNING: JAVA_HOME environment variable not found [minimal] Running
> install-minimal-pro Ant task
> ---------------------------------------------------------------------- '"java.exe"' is not recognized as an internal or external command,
> operable program or batch file. Checking Ant return code: OK
I've tried:
Setting the environments several ways (setx.exe, etc)
Running the bat in many ways, start-process, cmd, in an invoke-command, etc
If I reboot the server it will install fine. Also, if I run the batch directly in a command prompt it's fine.
Before I have to use an image with Java already installed, I want to understand why this is happening and ideally make it work.
Both SetEnvironmentVariable(..., "Machine") and setx set the variable in the registry. This value is used for future processes launched by explorer (such as after a reboot), but it is NOT set for the current process or its children. Your script needs to set the variables for the current process.
Using the .NET syntax:
[Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Java\jdk1.8.0_91", "Process")
Or, using PS syntax
$env:JAVA_HOME = "C:\Program Files\Java\jdk1.8.0_91"

How to start JBoss AS 7.1.1 on Windows?

I am new to JBOSS.I downloaded jboss-as-7.1.1.Final.zipand 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.
I tried to start server throught cmd.I open cmd in 2 ways
1.normally mode
Run as Admin (Admin Mode).
In 2 ways I get:
Calling "P:\Software\JBOSS\jboss-as-7.1.1.Final\bin\standalone.conf.bat"
'findstr' is not recognized as an internal or external command,
operable program or batch file.
then it stops.
So the JBoss server does not start.
I added Environment Variables like.
JBOSS_HOME : P:\Software\JBOSS\jboss-as-7.1.1.Final
JAVA_HOME : C:\Program Files\Java\jdk1.7.0_21
How can I run JBoss server and deploy projects in it on Window 7?
Add the following value to Right Click My Compuer -> Advanced -> Environment Variables -> System Variables -> Select Path variable -> append the below value.
C:\WINDOWS\system32
It should work with that change.
#All, Finally I got it,why I am getting this problem 'findstr' is not recognized as an internal or external command, operable program or batch file.
Because the following path C:\Windows\System32 was not set in Environment variables. I found through google.I fix it and run my server it's working great.
Thank you guys for your valuable suggestions.
You have to go to your bin folder P:\Software\JBOSS\jboss-as-7.1.1.Final\bin\ and then execute run.bat or standalone.bat
If you still get errors, you should delete your entire JBoss folder and then install it again and try to run it with the default settings. Once you've confirmed that works, change the settings 1 by 1 so that you know which setting caused your server to not start up.
You could better add it in to any IDE(eclipse) and then deploy your application. That should be easy to manage your applications

Can't run mvn command on windows from unpacked source archive

My laptop got stolen so I had to redownload Java and Maven and I can't seem to get Maven up and running, even though I had no problems last time. I have the following locations:
C:\Program Files\Java\jdk1.7.0_03
C:\Program Files\apache-maven-3.0.4
In my environment settings, I added the following system variables:
M2_HOME - C:\Program Files\apache-maven-3.0.4
JAVA_HOME - C:\Program Files\Java\jdk1.7.0_03
I updated my Path system variable so that the following would be at the beginning:
%JAVA_HOME%\bin;%M2_HOME%\bin;
All this I got from the Maven installation instructions. However, when I open a new command prompt and check the version, I get the following message:
'mvn' is not recognized as an internal or external command,
operable program or batch file.
Does anyone know what I am missing?
UPDATE
When I installed Java, I noticed java -version automatically started working without me having to do anything. Might there be a Java conflict somewhere?
Your path variable should have %M2_HOME%\bin instead of %M2%\bin
Check the properties of mvn.bat to see if it is blocked.

jenkins: error during ant build - java.exe not recognized

I've just started setting up a build server, using Jenkins.
Right now i have an extremely vanilla setup. Just trying to get it to run the default target of a specific build file. However whenever i run it jenkins reports this:
[build] $ cmd.exe /C '"ant.bat -file build.xml compileReleaseBuild && exit %%ERRORLEVEL%%"'
'"java.exe"' is not recognized as an internal or external command, operable program or batch file.
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
The odd thing is, i have my PATH and JAVA_HOME enviroment variables set up correctly, and i can run this command from the command line correctly. What is it that jenkins does that is different from running the commands by hand?
As stated by gareth_bowles, Jenkins runs as the system account on your machine. This means that any permissions or configuration (like your enviroment variables) have to be set in the system context as well. (more info here on setting env as the system account)

Categories