Поделиться через


Running Java8 on Azure web apps

Switching to Java 8 version has got easier in new Azure Portal. Below are list of instructions

1) Navigate to https://ms.portal.azure.com/

2) Select your Java Web app and Click on settings

 

3) Click on Application Settings in Settings bar

 

4) You should see drop-down's to select different java version and web container.

 

 

 

 

------------------------------------------------ Below content is deprecated in favor of New Azure Portal -------------------------------------------------------

Note :  Please refer https://azure.microsoft.com/en-us/documentation/articles/web-sites-java-custom-upload/ for changing java version in application server.

 

Java 1.8 binaries are pre-installed in Azure Web apps and Below are steps to activate it

 

1)     Go to configure tab in your webapp

 


 

2)     Add following content in app settings

Key : JAVA_HOME 

Value : D:\Program Files\Java\jdk1.8.0_25

3)     Navigate to your website kudu console - https://yourWebsiteName.scm.azurewebsites.net/Env and check if you have below content

 JAVA_HOME = D:\Program Files\Java\jdk1.8.0_25

4)     Set java bin path in debug console

 set PATH=%PATH%;%JAVA_HOME%/bin

 

 

5)     Check if changes are reflected

 Java –version

 

 

Note :  Please refer https://azure.microsoft.com/en-us/documentation/articles/web-sites-java-custom-upload/ for changing java version in application server.

 

Troubleshoot :

1) You can skip setting PATH variable from step 4 above and run java directly using below command

 D:\home>"%JAVA_HOME%"\bin\java -version
 

2) If you would like to make this change at application server level, please use below config file for tomcat. You can find more details @ https://azure.microsoft.com/en-us/documentation/articles/web-sites-java-custom-upload/

 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
 <system.webServer>
 <handlers>
 <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
 </handlers>
 <httpPlatform processPath="%HOME%\site\wwwroot\bin\tomcat\bin\startup.bat" 
 arguments="">
 <environmentVariables>
 <environmentVariable name="CATALINA_OPTS" value="-Dport.http=%HTTP_PLATFORM_PORT%" />
 <environmentVariable name="CATALINA_HOME" value="%HOME%\site\wwwroot\bin\tomcat" />
 <environmentVariable name="JRE_HOME" value="%JAVA_HOME%" /> 
 <environmentVariable name="JAVA_OPTS" value="-Djava.net.preferIPv4Stack=true" />
 </environmentVariables>
 </httpPlatform>
 </system.webServer>
 </configuration>
 As suggested by PERTU in comments try using JAVA_HOME1 if azure overrides value set in user interface 

Comments

  • Anonymous
    June 08, 2015
    If i set Java_Home in the properties it complains at run time that java isn't on the classpath. When you change the path on the Kudu  console it only seems to affect the console and not the running app. Any suggestions?

  • Anonymous
    June 11, 2015
    Hi Ben, I have added troubleshoot section in above blog. Check if that resolves your issue and let me know if you need more help.

  • Anonymous
    July 27, 2015
    You have a bug in the instructions. This is wrong: <environmentVariable name="JRE_HOME" value="%JAVA_HOME%binjava" /> It should be: <environmentVariable name="JRE_HOME" value="%JAVA_HOME%" /> In other words, Java home should not point to the Java binary. Instead, it should point to Java installation directory.

  • Anonymous
    July 27, 2015
    And by the way, it seems that Azure wants to override JAVA_HOME app setting sometimes due to some mysterious reasons with the value set in user interface (Configure -> JAVA VERSION -> 1.7.0_51 i.e. D:Program FilesJavajdk1.7.0_51 at the moment). It's better idea to use for example JAVA_HOME1 or something else to make sure Azure does not mess up things.

  • Anonymous
    August 13, 2015
    Hi Perttu, Thanks for letting us know, I made few changes. hope it fixes issue you reported.