본문 바로가기

BackEnd/난 자바를 공부한적이 없어요

자바 처음 시작

반응형

1. JDK(JAVA (se) Developement Kit) : 자바 개발에 사용되는 도구


JVM, 라이브러리, 개발에 필요한 소프트웨어등 이런것들을 모두 묶어둔것


자바 프로그램의 개발을 위한 소프트웨어와 라이브러리의 모음



2. JAVA 분류


- JAVA  SE(Standard Edition) :  일반적인 응용프로그램(파워포인트,워드등)일반적인 어플리케이션 개발에 사용되는 자바를 가르켜 java se라한다. 내가 데스크탑 컴퓨터에 설치할수있고 , 데스크탑용 컴퓨터에서 실행되는 자바프로그램의 개발에 필요한 모든것을 모아놓은것이라고 보자. java se는 다양한 기능 제공, 


- JAVA ME(Micro Edition) : 가벼워진 자바, 소형디바이스에 올릴수있는 자바


- JAVA EE(Enterprise Edition) : java se보다 상대적으로 더 큰 개념의 자바

기업환경에서 사용되는 솔루션개발을 위한 자바이다. 일반적인 어플리케이션 개발보다 훨씬 더 큰것을 요구. ee는 se를 당연히 포함, 더 많은것을 다룸


3. 디렉터리 구성


C:\Program Files\Java\jdk1.8.0_211\bin 폴더안에

javac.exe는 자바 컴파일러이고

java.exe 는 자바 런처이다.

bin은 binary의 줄임말 실행파일을 binary라 보통 말한다.


4. 명령프롬프트


명령프롬프트안에서 디렉토리가 가리키는 곳에서 test.exe명령을 내리면 

명령프로트는 이 디렉토리에서 먼저 test.exe 실행파일을 찾음 

하지만 찾지를 못하면

현재의 디렉토리만이 아닌 윈도우 운영체제에 등록되어있는

path라는 정보를 참조해서 path에 등록된 디렉토리안에서도 찾는다.

path에 값에 여러개의 디렉토리가 등록되면 그것을 쫙 다 찾음.

우리는 명령창에서 java.exe와 javac.exe를 실행하길 원함 

그래서 java.exe와 javac.exe가 존재하는 디렉토리를 path의 값으로 등록 필요

    

5. path등록방법


윈도우의 환경변수에

path라는 변수가 등록되어있다. 여기에다가 값을 등록할수 있다.

이미 path의 값에 여러값이 등록되어있음. 


6. java.exe와 javac.exe 실행


1) 자바실행  : 실행하면 사용법이 나온다


C:\Users\champ>java


사용법: java [-options] class [args...]

           (클래스 실행)

   또는  java [-options] -jar jarfile [args...]

           (jar 파일 실행)

여기서 options는 다음과 같습니다.

    -d32          사용 가능한 경우 32비트 데이터 모델을 사용합니다.

    -d64          사용 가능한 경우 64비트 데이터 모델을 사용합니다.

    -server       "server" VM을 선택합니다.

                  기본 VM은 server입니다..


    -cp <디렉토리 및 zip/jar 파일의 클래스 검색 경로>

    -classpath <디렉토리 및 zip/jar 파일의 클래스 검색 경로>

                  클래스 파일을 검색할 ;(으)로 구분된 디렉토리,

                  JAR 아카이브 및 ZIP 아카이브 목록입니다.

    -D<name>=<value>

                  시스템 속성을 설정합니다.

    -verbose:[class|gc|jni]

                  상세 정보 출력을 사용으로 설정합니다.

    -version      제품 버전을 인쇄한 후 종료합니다.

    -version:<value>

                  경고: 이 기능은 사용되지 않으며

                  이후 릴리스에서 제거됩니다.

                  실행할 버전을 지정해야 합니다.

    -showversion  제품 버전을 인쇄한 후 계속합니다.

    -jre-restrict-search | -no-jre-restrict-search

                  경고: 이 기능은 사용되지 않으며

                  이후 릴리스에서 제거됩니다.

                  버전 검색에서 사용자 전용 JRE를 포함/제외합니다.

    -? -help      이 도움말 메시지를 인쇄합니다.

    -X            비표준 옵션에 대한 도움말을 인쇄합니다.

    -ea[:<packagename>...|:<classname>]

    -enableassertions[:<packagename>...|:<classname>]

                  세분성이 지정된 검증을 사용으로 설정합니다.

    -da[:<packagename>...|:<classname>]

    -disableassertions[:<packagename>...|:<classname>]

                  세분성이 지정된 검증을 사용 안함으로 설정합니다.

    -esa | -enablesystemassertions

                  시스템 검증을 사용으로 설정합니다.

    -dsa | -disablesystemassertions

                  시스템 검증을 사용 안함으로 설정합니다.

    -agentlib:<libname>[=<options>]

                  <libname> 고유 에이전트 라이브러리를 로드합니다(예: -agentlib:hprof).

                  -agentlib:jdwp=help 및 -agentlib:hprof=help도 참조하십시오.

    -agentpath:<pathname>[=<options>]

                  전체 경로명을 사용하여 고유 에이전트 라이브러리를 로드합니다.

    -javaagent:<jarpath>[=<options>]

                  Java 프로그래밍 언어 에이전트를 로드합니다. java.lang.instrument를 참조하십시오.

    -splash:<imagepath>

                  이미지가 지정된 스플래시 화면을 표시합니다.

자세한 내용은 http://www.oracle.com/technetwork/java/javase/documentation/index.html을 참조하십시오.


2) javac실행 : 실행하면 사용법이 나온다


C:\Users\champ>javac


Usage: javac <options> <source files>

where possible options include:

  -g                         Generate all debugging info

  -g:none                    Generate no debugging info

  -g:{lines,vars,source}     Generate only some debugging info

  -nowarn                    Generate no warnings

  -verbose                   Output messages about what the compiler is doing

  -deprecation               Output source locations where deprecated APIs are used

  -classpath <path>          Specify where to find user class files and annotation processors

  -cp <path>                 Specify where to find user class files and annotation processors

  -sourcepath <path>         Specify where to find input source files

  -bootclasspath <path>      Override location of bootstrap class files

  -extdirs <dirs>            Override location of installed extensions

  -endorseddirs <dirs>       Override location of endorsed standards path

  -proc:{none,only}          Control whether annotation processing and/or compilation is done.

  -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process

  -processorpath <path>      Specify where to find annotation processors

  -parameters                Generate metadata for reflection on method parameters

  -d <directory>             Specify where to place generated class files

  -s <directory>             Specify where to place generated source files

  -h <directory>             Specify where to place generated native header files

  -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files

  -encoding <encoding>       Specify character encoding used by source files

  -source <release>          Provide source compatibility with specified release

  -target <release>          Generate class files for specific VM version

  -profile <profile>         Check that API used is available in the specified profile

  -version                   Version information

  -help                      Print a synopsis of standard options

  -Akey[=value]              Options to pass to annotation processors

  -X                         Print a synopsis of nonstandard options

  -J<flag>                   Pass <flag> directly to the runtime system

  -Werror                    Terminate compilation if warnings occur

  @<filename>                Read options and filenames from file


7. 컴파일 및 실행


1) 컴파일은 : 자바 확장자가 붙은 소스코드를 클래스 확장가가 붙은 실행파일로 바꾸는것


. java 확장자 파일이있는 디렉토리에서 

컴파일 : javac test.java 라고 명령어를 치면

class파일이 만들어진다

이때 자바 확장자 파일이 윈도우에서는 기본적으로 ISO-8859-1로 지정되어 있기에 맞춰져야 한다. UTF-8이 아님


2) RUN : 클래스 확장자가 붙은 파일을 실행하는것


실행 : java test 라고 치면 실행된다.

java라는 명령어는  test.class파일을 자바가상머신으로 전달하는 역할


public class test{

public static void main(String[] args) {

System.out.println("Hello world");

}

}


결과 : hello world!


참고 : https://cg-developer.tistory.com/431

https://cg-developer.tistory.com/113?category=841960











반응형