How to configure runtime? · Issue #367 · nvim-java/nvim-java · GitHub
Skip to content

How to configure runtime? #367

Description

@kien5436

Hello, I see that you have a PR #244 to change jdk but I don't understand how to use it. I have openjdk 17 and 21 on my machine and need to run projects on them. This is my setup (based on https://github.com/nvim-lua/kickstart.nvim):

        jdtls = {
          settings = {
            java = {
              configuration = {
                runtimes = {
                  {
                    name = 'openjdk-17',
                    path = java_paths['17'],
                    default = true,
                  },
                  {
                    name = 'openjdk-21',
                    path = java_paths['21'],
                  },
                },
              },
            },
          },
        },

...
require('mason-lspconfig').setup {
  ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
  automatic_installation = false,
  handlers = {
    function(server_name)
      local server = servers[server_name] or {}
      -- This handles overriding only values explicitly passed
      -- by the server configuration above. Useful when disabling
      -- certain features of an LSP (for example, turning off formatting for ts_ls)

      if 'jdtls' == server_name then
        require('java').setup {
          spring_boot_tools = { enable = true, version = '1.55.1' },
          jdk = { auto_install = false },
        }
      end

      server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
      require('lspconfig')[server_name].setup(server)
    end,
  },
}

seems it only loads config for jdk 17

Neovim version (nvim -v)

0.10.4

Operating system/version

MacOS 15.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions