Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JBoss as a windows service. Where can i set the JAVA_OPTS?

I'm running JBoss as a windows service, but i can't seem to find where i can configure the JAVA_OPTS to make it work properly. I need to set the Xms and the Xmx.

I have tried to just run JBoss manually (run.bat) and in the same file i set the JAVA_OPTS= -Xms128m -Xmx512m. And that works.

Here is my install.bat where i install the JBoss as a service:

set JBOSS_CLASS_PATH=%JAVA_HOME%\lib\tools.jar;%JBOSS_HOME%\bin\run.jar

rem copy /Y JavaService.exe D:\PROJECT\bin\JBossService.exe

JBossService.exe -install JBoss %JAVA_HOME%\jre\bin\server\jvm.dll -Djava.class.path=%JBOSS_CLASS_PATH% -start org.jboss.Main -stop org.jboss.Shutdown -method systemExit -out %PROJECT_HOME%\log\JBoss_out.log -err %PROJECT_HOME%\log\JBoss_err.log -current D:\PROJECT\bin
net start JBoss

When i look at the info about JBoss Application Server (http://localhost:8080/web-console/) i see this info:

JVM Environment
Free Memory: 9 MB
Max Memory: 63 MB
Total Memory: 63 MB

And i MUST have more Max Memory.

Does anybody know where i can set the JAVA_OPTS when running JBoss as a service?

like image 932
Ikky Avatar asked Mar 10 '10 15:03

Ikky


3 Answers

We use jbosssvc.exe to run JBoss as a service. It basically runs your run.bat, so you can include all the customizations you want.

http://community.jboss.org/wiki/JBossNativeWindows

In the bin directory of jboss, there's a service.bat that can install the service.

like image 54
karoberts Avatar answered Oct 03 '22 20:10

karoberts


@karoberts answer is correct, although is different between version 4 and 5:

In JBoss 4:

{jboss.home}\bin\run.bat

In JBoss 5:

{jboss.home}\bin\run.conf.bat

Which one are you using?

The

service.bat

script of jboss native calls run.bat so you should put your JAVA_OPTS in there using the syntax

set "JAVA_OPTS=%JAVA_OPTS% -Dyoutoptionsgoeshere

Note: you won't find the service.bat in the bin anymore since JBoss 5. It's in a different package.

like image 24
Luca Molteni Avatar answered Oct 03 '22 21:10

Luca Molteni


Another tip: If you have multiple Java Versions installed on your server and JBoss(4.2.3) service needs an older Version, you have to define the JAVA var in service.bat. If you use the run.bat also sometimes, then you need to define the JAVA var there too. I know that the service.bat calls the run.bat, but I tried just defining the JAVA var in the run.bat, when I then ran the service it ignored the new JAVA var content from run.bat

Here an example of how to set the JAVA var :

set JAVA_HOME=C:\Program Files (x86)\Java\jre6
set JAVA=%JAVA_HOME%\bin\java
like image 37
Charles Avatar answered Oct 03 '22 21:10

Charles