GithubHelp home page GithubHelp logo

java's Introduction

java

java's People

Contributors

yechanl90 avatar

Watchers

James Cloos avatar  avatar

java's Issues

file encoding에 따른 compile error

에러메세지

StandardOutput.java:14: error: unmappable character (0xEB) for encoding x-windows-949
                System.out.println("?몴以?異쒕젰硫붿냼?뱶");
                                                   ^

에러분석

해당 에러는 utf-8로 인코딩된 코드를 자바 컴파일러에서 한글 윈도우의 기본 인코딩을 따라서 ms949 방식으로 읽으려고 시도 했지만 실패했기때문에 발생

해결방법

javac 컴파일 옵션에 encoding을 명시

C:\Temp>javac StandardOutput.java -encoding UTF-8 

java package와 java.lang.ClassNotFoundException

에러메세지

C:\Users\yechan\Desktop\study\java\basic\bank\bin\javabank>java javabank.Account
Error: Could not find or load main class javabank.Account
Caused by: java.lang.ClassNotFoundException: javabank.Account

에러분석 및 해결

해당 클래스를 찾지못해 발생한 Exception. 실제 문제의 원인은 잘못된 디렉토리에서 byte코드를 수행시키려함. bin 위치에서 위와같이 수행시 정상적으로 동작함

src와 bin 디렉토리를 별도 둔 상황에서 package를 명시한 java code를 아래와 같이 컴파일하면, bin 디렉토리 하위에 패키지로 이름으로 서브 디렉터리가 생성이 되고 그 하위에 클래스파일이 생성이됨. 이때 컴파일된 클래스의 FQCN(Fully Qualified Class Name)은 javabank.Account이다.

C:\Users\yechan\Desktop\study\java\basic\bank\src\javabank>javac -d ..\..\bin Account.java -encoding UTF8

관련 source code

package javabank;

public class Account {
	private String accountNo;
	private long balance;
	
	public void deposit(long amount) {	// deposit  예금하다
		balance = balance + amount;
	}
	
	public void withdraw(long amount) {	// balance 계좌잔고
		balance = balance - amount;
	}
	
	public long getBalance() {
		return balance;
	}

	public static void main(String[] args) {
		System.out.println("패키지 테스트");
	}
	
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.