0

This is my listing listing

whose code is:

\lstset{
  inputencoding=utf8/latin1,
  language=Java,                % choose the language of the code
  numbers=left,                   % where to put the line-numbers
  stepnumber=1,                   % the step between two line-numbers.        
  numbersep=5pt,                  % how far the line-numbers are from the code
  backgroundcolor=\color{white},  % choose the background color. You must add \usepackage{color}
  showspaces=false,               % show spaces adding particular underscores
  showstringspaces=false,         % underline spaces within strings
  showtabs=false,                 % show tabs within strings adding particular underscores
  keepspaces=true, 
  basicstyle=\footnotesize\ttfamily,
  commentstyle=\color{greencomments},
  keywordstyle=\color{bluekeywords}, 
  stringstyle=\color{redstrings},
  identifierstyle=\color{types},
  tabsize=2,                      % sets default tabsize to 2 spaces
  captionpos=b,                   % sets the caption-position to bottom
  breaklines=true,                % sets automatic line breaking
  breakatwhitespace=true,         % sets if automatic breaks should only happen at whitespace
}

    \begin{lstlisting}
        @Override
        public boolean login(@NotNull Account account)
                                        throws IOException, InterruptedException {
        
        if (account.getEmail() == null)
            return false;
        
        if (account.getPassword() == null)
            return false;
        
        if (!respectPattern(String.valueOf(account.getPassword())))
            return false;
        
        String URL = getBaseUrl();
        URL = URL.concat("/" + REPOSITORY);
        URL = URL.concat("/admin-login");
        
        final Map<String, Object> values = new HashMap<>();
        values.put("key", account.getEmail());
        values.put("password", String.valueOf(account.getPassword()));
        
        ObjectMapper objectMapper = ObjectMapperCreator.getNewObjectMapper();
        String requestBody = objectMapper.writeValueAsString(values);
        
        HttpClient httpClient = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest
                                                    .newBuilder()
                                                    .uri(URI.create(URL))
                                                    .header("Content-Type", "application/json")
                                        .POST(HttpRequest.BodyPublishers.ofString(requestBody))
                                                    .build();
        
        HttpResponse<String> response = httpClient.send(request,
        HttpResponse.BodyHandlers.ofString());
        
        return response.statusCode() == 200 &&
                        setAuthenticationResultIntoAccount(response, account);
    }
    \end{lstlisting}

How can I change colors to default Java ones and let auto-indent?

1 Answer 1

0

There is no "default Java coloring". You have to change colors manualy if you don't like them. Eg. try to switch

keywordstyle=\color{black}

Or define your own color:

\definecolor{mauve}{rgb}{0.3,0,0.3}

then

keywordstyle=\color{mauve}
1
  • I want to change that blue-sky color at login etc to black
    – user225381
    Oct 5, 2020 at 19:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .