How to call a java package Packages.java.net.InetAddress.getByName("www.google.com")

droid
Kilo Explorer

I am trying to call  Packages.java.net.InetAddress.getByName("www.google.com") in "Scripts - Background"

But this gives me an error -  

Script -

var i = Packages.java.net.InetAddress.getByName("www.google.com");

gs.print(i);

Result -

Attempted script access to inaccessible member denied - java.net.InetAddress:getByName:(Ljava/lang/String;)Ljava/net/InetAddress;
Evaluator: java.lang.SecurityException: Illegal access to method getByName(string) in class java.net.InetAddress       Caused by error in script at line 1   ==>     1: var i = Packages.java.net.InetAddress.getByName("www.google.com");             2: gs.print(i);
Background message, type:error, message: Illegal access to method getByName(string) in class java.net.InetAddress

Although a few other packages like URL executes fine -

Script -

var i = new Packages.java.net.URL("http://www.google.com");

gs.print(i.getHost());

Result -

*** Script: www.google.com

Why would InetAdress not work and other java.net classes work?

10 REPLIES 10

Teena Singh
ServiceNow Employee
ServiceNow Employee

Pranay,


Glad to see that you are using the Community to learn more.


The Customer Experience team is striving to ensure that customer queries posted from the HI Service Portal are answered in timely and accurate fashion.


If you feel your question has been resolved, please mark the appropriate reply in the thread as being the Correct Answer.


This enables other customers to learn from your thread.


Thank you in advance.



If you are viewing this from the community inbox you will not see the correct answer button.   If so, please review How to Mark Answers Correct From Inbox View.



Regards,


Teena Singh
Customer Experience: UX Strategy and Customer Insights
teena.singh@servicenow.com


ServiceNow


Screen Shot 2017-01-19 at 8.55.52 AM.png