공식사이트에서 캡처 이미지를 이용해보겠다.
Copy <! DOCTYPE html >
< html lang = "en" >
< head >
< meta charset = "UTF-8" >
< meta http-equiv = "X-UA-Compatible" content = "IE=edge" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< title >Document</ title >
</ head >
< body >
< div >
< h1 >안녕하세요 신비한 비 티스토리 블로그 입니다!</ h1 >
</ div >
< div >< h3 >티스토리블로그:</ h3 ></ div >
< url >https://rainsister.tistory.com/</ url >
< div >< h3 >깃북블로그:</ h3 ></ div >
< url >https://app.gitbook.com/o/oa8n0se1zcxXR1QCxPlj/home</ url >
</ body >
</ html >
내가 설치한 java 버전 그리고 home 경로를 파악해보자. 맥 기준 터미널에서
Copy /usr/libexec/java_home -V
Matching Java Virtual Machines (7):
18.0.2.1 (x86_64) "Eclipse Adoptium" - "OpenJDK 18.0.2.1" /Users/blake/Library/Java/JavaVirtualMachines/temurin-18.0.2.1/Contents/Home
17.0.5 (arm64) "Eclipse Adoptium" - "OpenJDK 17.0.5" /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
16.0.2 (x86_64) "Eclipse Temurin" - "Eclipse Temurin 16" /Library/Java/JavaVirtualMachines/temurin-16.jdk/Contents/Home
11.0.17 (arm64) "Eclipse Adoptium" - "OpenJDK 11.0.17" /Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home
11.0.11 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 11" /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
1.8.0_345 (x86_64) "Eclipse Temurin" - "Eclipse Temurin 8" /Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home
1.8.0_292 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
/Users/blake/Library/Java/JavaVirtualMachines/temurin-18.0.2.1/Contents/Home 로 확인 인된다.
jwebserver 를 시작하기 위해 bin 폴더까지 이동한다.
Copy ./jwebserver
Binding to loopback by default. For all interfaces use "-b 0.0.0.0" or "-b ::".
Serving /Users/blake/Library/Java/JavaVirtualMachines/temurin-18.0.2.1/Contents/Home/bin and subdirectories on 127.0.0.1 port 8000
URL http://127.0.0.1:8000/
127.0.0.1 - - [05/1월/2023:16:16:31 +0900] "GET /index.html HTTP/1.1" 200 -
127.0.0.1 - - [05/1월/2023:16:16:59 +0900] "GET /index.html HTTP/1.1" 200 -
Copy -h or - ? or --help
Prints the help message and exits.
-b addr or --bind-address addr
Specifies the address to bind to. Default: 127.0.0.1 or ::1 (loopback). For
all interfaces use -b 0.0.0.0 or -b ::.
-d dir or --directory dir
Specifies the directory to serve. Default: current directory.
-o level or --output level
Specifies the output format. none | info | verbose. Default: info.
-p port or --port port
Specifies the port to listen on. Default: 8000.
-version or --version
Prints the version information and exits.
Copy jwebserver -p 9000 -d / -b 127.0.0.1 -o info
루트 / 디렉토리의 내용을 확인 할수 있다.
jwebserver 구동(with java code)
테스트용 메인함수 하나 만든다.
Copy public static void main( String [] args) {
System . out . println ( "구동완료!!!" );
var addr = new InetSocketAddress( 9898 ) ;
var server = SimpleFileServer . createFileServer (
addr , Path . of ( "/" ) , SimpleFileServer . OutputLevel . INFO );
server . start ();
}
확인을 위해 9898 포트 새로 띄여보면 정상적으로 시작된걸 알수 있다.