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

17,988

Solution 1

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.

Solution 2

@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.

Solution 3

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
Share:
17,988
2xj
Author by

2xj

Updated on June 04, 2022

Comments

  • 2xj
    2xj almost 2 years

    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?

  • 2xj
    2xj about 14 years
    Thanks, i'll take a look at that
  • 2xj
    2xj about 14 years
    I use JBoss 4, so i don't think it is included in that version
  • 2xj
    2xj about 14 years
    i'm using JBoss 4, and as i said in the second paragraph, i edited the run.bat and executed it, and it worked perfect. But when i installed it as a service, it would not work. I only get 64MB as max memory.
  • karoberts
    karoberts about 14 years
    I use JBoss 4.2.3. There's a link on the page I linked to download the jboss native binaries for your platform.
  • 2xj
    2xj about 14 years
    Ah, found it now :) I will try that now. Any tip how i can get set the jboss_out.log and the JBoss_err.log path, as i had in my main post : "-out %PROJECT_HOME%\log\JBoss_out.log -err %PROJECT_HOME%\log\JBoss_err.log"
  • Luca Molteni
    Luca Molteni about 14 years
    The service.bat file print the JAVA_OPTS in the run.log file. Would you mind posting your output?
  • karoberts
    karoberts about 14 years
    In service.bat, add redirection to the "call run.bat" line under cmdStart:, something like "call run.bat > out.log 2> err.log"
  • 2xj
    2xj about 14 years
    Did not install it as a service in using service.bat, but i'm trying that tomorrow :)
  • 2xj
    2xj about 14 years
    Thanks! I'll try that tomorrow :)
  • 2xj
    2xj about 14 years
    Thanks for great help. I still did not get the out.log and the err.log, but i guess the out.log is the same as the run.log now. But how about the err.log? Any idea on that one? Here is what i changed under the cmdStart: call run.bat >out.log 2>err.log < .r.lock >> run.log 2>&1
  • djangofan
    djangofan almost 11 years
    If you run multi-instance with ports-01 configurations, etc. , I see know way for this wrapper to load the "-Djboss.server.base.dir=..\ports-01" option when the service runs. This being the case, you must hard-code the option in standalone.conf.bat which precludes you from running multiple instances in the same directory. Chicken or the egg.