728x90

 


JDK

JDK
JRE + javac, jar, debugging tools, javap
JVM + java, javaw, lib, rt.jar
Class Loader
Execution Engine
Runtime Data Area

 
Interpreter JIT Compiler Garbage
Collector

Java Source(.java) 

-(javac,자바컴파일러)-> Java Byte Code(.class)

-(ClassLoader, JVM 동적으로 클래스로딩)-> JVM 이동

1. (Interpreter)-> 바이트코드 읽고 요청내용 실행

2. (JIT Compiler)-> 기계어 변환후 실행


JVM

= ClassLoader + Execution Engine(Interpreter+JIT Compiler+GC) + Runtime Data Area

Runtime Data Area (JVM Memory)
JVM Language Stack


Heap Space
Method Area
Native Method Stack
PC Register
Young Generation
Old Generation
Permanent Generation
-> Metaspace(JDK1.8)

Code Cashe 
Eden
To Survivor Virtual
Old
Virtual
Runtime Constant Pool
Virtual Thread
1~N


Compile Native Virtual
From Survivor Field & Method Data
  Code

1. JVM Language Stack

: Last In First Out :LIFO , 메서드 호출 시마다 스택프레임 생성 수행후 삭제 , 메서드 안에서 사용되어지는 값(매개변수, 지역변수, 리턴값, 연산시 일어나는임시값)

2. Heap Space

-Xms                    최소 Heap 공간(Eden +Survivor+Old)
-Xmx                    최대 Heap 공간(Eden +Survivor+Old + Virtual)
+ Xms, Xmx 동일하게 셋팅  메모리 추가할당 시 WAS ms 정도 멈춤현상 주의

Young Generation : Minor GC 발생

Eden : 새로 생성된 대부분의 객체가 처음 위치하는 영역, GC 발생후 살아남은 객체는 Survivor1 or Survivor2이동

Survivor1,  Survivor2 : 둘중 하나의 영역이 꽉차면 참조없는 객체삭제, 살아남은 객체가 비워진 다른 Suvivor 영역이동

-XX:NewSize          최소 Young 공간 (Eden + Survivor)
-XX:MaxNewSize    최대 Young 공간 (Eden + Survivor + Virtual)
-XX:SurvivorRatio   Eden(new)/Survivor  영역 비율
-XX:NewRatio        Young(Eden + Survivor)/Old 

Old Generation : Major GC(Full GC) 발생

Old : Survivor에서 살아남은 객체만이 Old 영역이동, Old영역은 Young영역보다 크게 할당

3. Method Area = Class Area = Code Area = Static Area

Permanent :  Runtime Constant Pool + Field & Method Data + Code

             클래스, 인터페이스에 대한 런타임상수, 멤버변수(필드), 클래스변수(**Static), 생성자 메서드 저장

              *Java8에서 Metaspace 영역으로 교체 OutOfMemoryError 이슈

-XX:PermSize         초기 Perm size
-XX:MaxPermSize   최대 Perm size
+ 1.8 에서는 무시 Metaspace 대체 힙 메모리 일부
-XX:MaxMetaspaceSize

4. Native Area

Code Cashe  :  JIT방식: Just In Time  : Java -> ByteCode-> 기계어

                  변환 시간 절약위해 많이 쓰는 코드 기계어로 변환시켜 저장해둠

5. PC Register

현재 수행중인 JVM 명령과 주소 저장, CPU내의 기억장치, Thread가 생성될 떄 마다 생성

(이부분은 정확하지 않음 팁 소스에 따라 다르니.. 긇어모음)
최대 할당메모리  Xmx + MaxPermSize
Full GC 시간을 줄이는게 중요, 큰 요구사항없다면  Heap Size 1G
ex)
-Xmx1024m –Xms1024m -XX:MaxNewSize=384m -XX:MaxPermSize=128m 
>>전체  1024+138+300~500  : 1.5G
New : Old 비율은 서버 어플리케이션 1:2 적당  >> MaxNewSize = Xmx / 3
Perm 128M 적당, 256M을 대부분 넘지 않음

출처

tcpschool.com/java/java_intro_programming >> 자바프로그램 실행과정

epthffh.tistory.com/entry/JVM-%EB%A9%94%EB%AA%A8%EB%A6%AC-%EA%B4%80%EB%A0%A8-%EC%84%A4%EC%A0%95 >> 메모리 설정팁

javaslave.tistory.com/23>> java 옵션

atin.tistory.com/625

johngrib.github.io/wiki/java8-why-permgen-removed/    >>1.7 vs 1.8

mirinae312.github.io/develop/2018/06/04/jvm_memory.html  >>JVM Heap 메모리구조 간단히 보기

JVM MEMORY
JDK 

 

 

728x90
728x90

플랫폼 

1. 단상

2. "사용 기반이 되는" 컴퓨터 시스템·소프트웨어

자바 플랫폼

- 일반적 플랫폼: 하드웨어와 거기에 설치된 운영체제

- 자바 플랫폼: 소프트웨어 플랫폼, 다른 여러 운영체제에 설치 가능

- 자바 플랫폼은 자바 API와 자바 VM 으로 구성된다. 

 

 

 

자바 API

: 프로그램에 사용되도록 이미 만들어져 제공되는 소프트웨어 커모넌트 ex) java.lang

자바 VM = JVM

: Java 플랫폼의 기초, 여러 하드웨어 플랫폼에서 설치= 플랫폼 독립적=아키텍쳐 중립적

: 구동엔진 + 실행환경

: 가비지 컬랙션 수행

JRE = JVM + 자바라이브러리, 등

JDK = JRE + 개발도구. 

Main 메소드

: 자바는 어플리케이션이 실행되면 제일 메인 메소드부터 실행된다. 

package me.fun.java;
public class MainTest{
	public static void main(String[] args){
    	System.out.println("HelloWorld");
    }
}

제임스 고슬링

자바의 아버지, 캐나다 소프트웨어 개발자. 

1990년 말 썬 마이크로 시스템즈에서 객체 지향의 새로운 언어인 OAK 개발. 

 

728x90

8. Introducing Spring Boot

Spring Boot makes it easy to create stand-alone, production-grade Spring-based Applications that you can run. We take an opinionated view of the Spring platform and third-party libraries, so that you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.

You can use Spring Boot to create Java applications that can be started by using java -jar or more traditional war deployments. We also provide a command line tool that runs “spring scripts”.

Our primary goals are:

  • Provide a radically faster and widely accessible getting-started experience for all Spring development.
  • Be opinionated out of the box but get out of the way quickly as requirements start to diverge from the defaults.
  • Provide a range of non-functional features that are common to large classes of projects (such as embedded servers, security, metrics, health checks, and externalized configuration).
  • Absolutely no code generation and no requirement for XML configuration.

9. System Requirements

Spring Boot 2.0.3.RELEASE requires Java 8 or 9 and Spring Framework 5.0.7.RELEASE or above. Explicit build support is provided for Maven 3.2+ and Gradle 4.

9.1 Servlet Containers

Spring Boot supports the following embedded servlet containers:

You can also deploy Spring Boot applications to any Servlet 3.1+ compatible container.

 

8. 스프링 부트 소개

스프링 부트는 만들기 쉽게 합니다. 독립형의, 제품 수준의 스프링 기반의 어플리케이션을, 당신이 실행할 수 있는

우리는 스프링 플랫폼의 여러 라이브러리의 의견을 수렴하여, 당신이 힘들지 않게 시작할수 있게 했습니다. 

대부분의 스프링 부트 어플리케이션은 작은 스프링 환경설정만을 필요로 합니다. 

당신은 스프링 부트를 이용할 수 있습니다. 자바 어플리케이션을 만들때, "java -jar" 나 더 전통적인 war 를 디플로이(전개)하는 방법으로. 

우리는 또한 “spring scripts”.라 불리는 커멘드 라인 툴(cmd 툴)도 제공합니다. 

우리의 주 목적:

    • 급격히 빠르고 광범위하게 접근가능하게 시작할 수 있는 경험을 모든 스프링개발자에게 제공
    • opinionated view : 요구사항의에 맞게 기본설정에서 빠르게 벗어날수 있다. 
    • 비 함수적 기능- 보통 많은 클래스의 프로젝트-범위를 제공합니다. 임베디드서버, 보안, 메트릭스, 상태체크, 외부 환경설정과 같은
    • 전혀, XML환경설정을 위한 코드작성과 필수조건들이 없습니다. 

9. 시스템 요구사항

(스프링 부트 2.0.3.RELEASE 일때)

9.1 서블릿 컨테이너

Java 8, 9 , Spring Framework 5.0.7 , 메이븐 3.2 Gradle 4

Tomcat 8.5 , 서블릿 3.1 이상

stand-alone  독립형의

opinionated view 고집있는, 독선적인  =opinionated out of the box

convention 관습, 관례

production-grade 제품수준의

fuss 불평, 화, 안달하다. 

take an objective view 객관적으로 보다. 

deployments 전개, 배치

primary goals  주목적

radically  근복적인, 과격한, 급진주의의

diverge   벗어나다, 나뉘다. 갈라지다.

https://docs.spring.io/spring-boot/docs/2.0.3.RELEASE/reference/htmlsingle/#getting-started-introducing-spring-boot

 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.example</groupId>
	<artifactId>myproject</artifactId>
	<version>0.0.1-SNAPSHOT</version>

	<!-- Inherit defaults from Spring Boot -->
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.0.3.RELEASE</version>
	</parent>

	<!-- Add typical dependencies for a web application -->
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
	</dependencies>

	<!-- Package as an executable jar -->
	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>
@SpringBootApplication
public class SpringBootGettingStartedApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootGettingStartedApplication.class, args);
    }

}

https://docs.spring.io/spring-boot/docs/2.0.3.RELEASE/reference/htmlsingle/#getting-started-maven-installation

 

Spring Boot Reference Guide

This section dives into the details of Spring Boot. Here you can learn about the key features that you may want to use and customize. If you have not already done so, you might want to read the "Part II, “Getting Started”" and "Part III, “Using Spring Boot

docs.spring.io

 

http://start.spring.io

불러오는 중입니다...

메이븐 기본 프로젝트 구조와 동일 

● 소스 코드 (src\main\java) 

● 소스 리소스 (src\main\resource) 

● 테스트 코드 (src\test\java) 

● 테스트 리소스 (src\test\resource) 
 
메인 애플리케이션 위치 

● 기본 패키지 - ex) me.fun.springbootgettingstarted;   

>> 이 위치부터 스캔시작, 다른 위치의 경우 컴포넌트 스캔이 안됨. 

728x90

 

new BigDecimal(20).compareTo( new BigDecimal(20)) 0

 new BigDecimal(20).compareTo( new BigDecimal(30)) -1

 new BigDecimal(20).compareTo( new BigDecimal(10)) 1

Specified by:compareTo in interface Comparable<BigDecimal>Parameters:val - BigDecimal to which this BigDecimal is to be compared.Returns:-1, 0, or 1 as this BigDecimal is numerically less than, equal to, or greater than val.

 

.divide(sumBal, 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100));

 

728x90

#jsp modify without restart tomcat

server.jsp-servlet.init-parameters.development=true

spring.resources.chain.enabled=true



728x90

tomcat servlet-api.jar 의 설정이.. 미묘하게 안맞아서.. 테스트 중이 었는데...

java lib 와 tomcat lib 에 중복에서 servlet-api.jar 등록되니 까.. 이런 에러가 났다...

'For Real > Java & Spring' 카테고리의 다른 글

BigDecimal  (0) 2019.05.17
스프링 부트 jsp js 바로 수정가능  (0) 2019.03.19
[방통대 자바프로그래밍 4강]클래스, 상속  (0) 2019.03.04
[방통대 자바프로그래밍 1~3강]기본문법  (0) 2019.02.26
java version  (0) 2019.02.26
728x90

생성자 : 생성자의 이름은 클래스 이름과 같음

반환형을 선언하지 않음

여러 생성자 저으이 가능

접근제어자는  보통 public (private 도 가능은 함)

기본생성자 = 인자가 없는 생성자 - default 생성자.   

생성자 전혀 없으면 자동으로 컴파일러가 만들어줌. 

부모 클래스에서 기본생성자 자동호출 super()


static 필드  = 정적필드 = 클래스변수

클래스의 모든 객체가 공유하는 데이터 : 객체생성없이 항상사용가능, 어떤 객체도 값을 변경할 수 있음. 

클래스이름.정적필드. 

static 메소드 = 정적메소드, = 클래스 메소드

객체와 무관하게 호출되고 시행됨... 몸체에 this 사용불가

static 필드와 인자를 가지고 작업함

클래스 이름.정적메소드() 

ex) Math.sqrt(2.0) , Integer.parseInt("120")

final 필드   자주 static과 함께 사용됨

final 메소드  자식으로 상속은 가능하나 재정의 할 수 없는 메소드

   JAVA8  초기화 블록 실행순서

   데이터 필드 선언문에서 초기화 >> 초기화 블록 >> 생성자 생성


 클래스 재사용 

: 합성 .....기존클래스를 내부에 멤버로 사용  :: has-a 관계

: 상속 : 부모 로 사용. 






+ Recent posts