> For the complete documentation index, see [llms.txt](https://viva.gitbook.io/project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://viva.gitbook.io/project/kai-fa/java.md).

# Java

## 安装

### mac

1、安装openjdk-1.8

```
brew tap AdoptOpenJDK/openjdk
brew install adoptopenjdk8
```

2、安装maven

```
brew install maven
```

3、maven默认会捆绑安装java-1.16，修改maven所使用的java运行时版本，创建/etc/mavenrc或\~/.mavenrc文件，设置以下内容

```
JAVA_HOME=`/usr/libexec/java_home -v 1.8`
```

## Q\&A

Q：拉取jar包时maven-default-http-blocker报错

A：编辑maven配置文件（可通过mvn -v获取安装目录），将下方部分注释

```
<mirror>
    <id>maven-default-http-blocker</id>
    <mirrorOf>external:http:*</mirrorOf>
    <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
    <url>http://0.0.0.0/</url>
    <blocked>true</blocked>
</mirror>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://viva.gitbook.io/project/kai-fa/java.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
