Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

New to Java: Trying to create 2 dimensional string array but getting NullPointer

user580947Dec 7 2019 — edited Dec 9 2019

Hi,

I'm a rookie at Java so please be kind.

I'm trying to create a 2 dimensional array where I'm putt in country codes in column 0 and country names in column 1 using the ISO-3166.

Below is my method but i keep getting a Null Pointer Exception and I can' figure out why.  I believe my issue is in the way I'm putting my values in the array but I'm not sure what I'm doing wrong.

public class BrowseISDO3166Test {

     public static void main(String[] args) {

          BrowseISDO3166Test object = new BrowseISDO3166Test();

          object.init();

     }

     String[][] countries;

     public void init() {

          String[] countryCodes = Locale.getISOCountries();

          int x = 0;

          for (String countryCode : countryCodes) {

               Locale obj = new Locale("", countryCode);

               String code = obj.getCountry();

               String name = obj.getDisplayCountry();

               countries[x][0] = code;

               countries[x][1] = name;

               x++;

           }

     }

}

Can someone explain to me what I'm doing wrong...

Thanks in Advance

JavaRookie

This post has been answered by mNem on Dec 8 2019
Jump to Answer

Comments

StefanP-Oracle

Hi

RMI use random ports for communication between the stub and the remote object

for pass this traffic to firewall,

the solution is to tunnel RMI traffic over HTTP

please check:

https://docs.oracle.com/javase/8/docs/platform/rmi/spec/rmi-arch6.html

3.5 RMI Through Firewalls Via Proxies

Regards

Stefan

3363700

Hi Stefan

thank for your answer,

However i have found here:

https://docs.oracle.com/javase/8/docs/api/java/rmi/server/RMISocketFactory.html

that the http tunnelling is deprecated, and "are subject to removal ..."

There's just no other way to use RMI with a Firewall?

Best Regards

Marco

1 - 2

Post Details

Added on Dec 7 2019
3 comments
649 views