I have these variables:
private String name = "name";
private String password = "password";
private String authString = name + ":" + password;
private byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
private String authStringEnc = new String(authEncBytes);
And in my Java program I have the below code:
HttpURLConnection.setRequestProperty("Authorization", "Basic " + authStringEnc);
This gives me the following error:
Cannot make a static reference to the non-static field authStringEnc
If I then change my variables to static I get the below error:
Cannot make a static reference to the non-static method setRequestProperty(String, String) from the type URLConnection
How do I resolve this?