JAVA reference

<p><strong>&nbsp;1.&nbsp;Runtime Environment</strong></p> <p>The following Java runtime environment is available:</p> <ul> <li>&nbsp;Java8</li> </ul> <p><strong>2.&nbsp;</strong><strong>Instance in JAVA</strong></p> <p>To enable programming in Java, you need to write a class first to achieve then entry main method. Please find a simple instance below:</p> <p>package demo;</p> <p>import com.google.gson.JsonObject;</p> <p>public class Demo {</p> <p>public static JsonObject main(JsonObject args) throws JSONException, AuthException&nbsp; {</p> <p>&nbsp;&nbsp;&nbsp; String name = &quot;pauser&quot;;</p> <p>&nbsp;&nbsp;&nbsp; if (args.has(&quot;name&quot;))</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name = args.getAsJsonPrimitive(&quot;name&quot;).getAsString();</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;JsonObject response = new JsonObject();</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response.addProperty(&quot;greeting&quot;, name + &quot;!&quot;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>return response;</p> <p>&nbsp;&nbsp;&nbsp; }&nbsp;</p> <p>}</p> <p>The Java runtime environment of the Compute platform only supports JAR package uploading for compiling Demo.java into JAR</p> <p><strong>(1)&nbsp;&nbsp;&nbsp; </strong><strong>Package Name/Class Name</strong></p> <p>No special requirements for package name and class name. But they need to be in compliance with Java specifications and corresponding with the entry when the function is created. Like the instance mentioned above, its package name is demo and its class name is Demo. You should select the demo. Demo entry in the format &ldquo;<code>{package}.{class}</code>&rdquo;.</p> <p><strong>(2)&nbsp;&nbsp;&nbsp; </strong><strong>Request Parameters</strong></p> <p>Request parameters in JSON format only.</p> <p><strong>(3)&nbsp;&nbsp;&nbsp; </strong><strong>Return Value</strong></p> <p>Function running results returned in JSON format.</p>
Did the above content solve your problem? Yes No
Please complete information!

Call us

400-151-8800

Email us

cloud@pingan.com

Online customer service

Instant reply

Technical Support

cloud products