Eclipse로 Java 프로젝트를 Run/Debug 시에 실행중 PermGen Space 에러가 나는경우가 있다.

이때는 VM 설정을 다음과 같이 수정한다.


  • Preferences > Java > Installed JREs > JRE 선택 > Edit > Default VM Arguments에 다음과 같이 입력 후 Finish
    • -XX:MaxPermSize=512m


Posted by leechwin
,

Eclipse를 실행시에 Java가 설치되어있는데도 다음과 같은 에러가 발생하는 경우가 있다.



이때에는 Eclipse 실행파일과 같은 경로에 위치하고 있는 eclipse.ini 파일을 열어서 다음 부분을 수정한다.

  • -xmx1024m 를 -xmx512m 으로 수정

이후 Eclipse가 실행이 된다.


Reference: http://stackoverflow.com/questions/7302604/eclipse-error-failed-to-create-the-java-virtual-machine


Posted by leechwin
,

Eclipse 에서 Java Code Convention 을 설정 후 해당 룰에 해당하는 xml 파일로 대 Java 파일들을 포멧팅하는 방법에 대해 알아보자.


대량의 파일을 포멧팅할때 Eclipse Command-line 옵션과 변환된 룰파일을 사용하여 포멧팅 가능하다.


Eclipse code format from command line

Eclipse를 이용하여 command line 상태에서 java code formtting을 수행하는 방법을 알아보자.


다음과 같이 Eclipse Runtime Options을 이용하여 Java Code Formatter를 command line에서 수행 가능하다.

  • eclipse -application <id> (Runtime) // id는 eclipse product id를 의미

Eclipse내에 내장된 Java Code Formatter의 product id는 다음과 같다.

  • org.eclipse.jdt.core.JavaCodeFormatter

Eclipse Runtime Options을 이용하여 JavaCodeFormatter를 실행하는 예제 및 옵션은 다음과 같다.

Usage: eclipse -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter [ OPTIONS ] -config <configFile> <files>

   <files> Java source files and/or directories to format.

           Only files ending with .java will be formatted in the given directory.

   -config <configFile> Use the formatting style from the specified properties file.

                        Refer to the help documentation to find out how to generate this file.

OPTIONS:

 -help Display this message.

 -quiet Only print error messages.

 -verbose Be verbose about the formatting job.


JavaCodeFormatter의 Command line에서 쓰이는 config 파일형식은 Eclipse Coding Convention 설정에서 정의된 xml 파일 형식이 아니다.
따라서 xml 파일을 config 파일로 바꾸는 일이 필요하다.

xml 파일을 config 파일로 변환하기 위해 다음과 같이 수행한다.

  • Eclipse에서 아무 Java 프로젝트를 생성
  • Project 선택 후 우클릭 > Properties 메뉴 선택
  • Java Code Style > Formatter > Enable project specific settings 선택 > Active profile에서 TIDE_JAVA_CONVENTION.xml 을 import 하거나 메뉴이 이미 있다면 선택
  • Apply > OK
  • 생성한 Java 프로젝트 경로로 이동
  • 프로젝트 경로 하위에 .settings 폴더밑의 org.eclipse.jdt.core.prefs 파일이 config 파일이므로 이를 원하는 곳에 복사해놓는다.

ConfigFile을 생성했으면 다음과 같이 실행 가능하다.

$ {eclipse path}/eclipse -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter -verbose -config {configFile path} {source file path}


// example

$ /home/leechwin/eclipse/eclipse -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter -verbose -config /home/leechwin/eclipse/org.eclipse.jdt.core.prefs /home/leechwin/git/org.leechwin.com/src/


References


Posted by leechwin
,

Eclipse 에서 Java Code Convention 을 설정 하는 법에 대해 알아보자.

Eclipse Preference 에서 Java Code Formate 에 대한 여러가지 설정이 가능하다.


Eclipse Java Formatter

Eclipse에서 Ctrl + Shift + F 를 누르면 해당 파일에 코딩 컨벤션 룰이 적용되게 하는 방법

  1. 컨벤션룰 파일을 다운로드
    1. JAVA_CONVENTION.xml

  2. Eclipse에서 다음 설정으로 이동
    1. Preference > Java > Code Style > Formatter
  3. Formatter 설정
    1. Import 버튼 클릭 > 다운받은 컨벤션룰 파일을 선택 > Apply > OK




Eclipse Java Save Actions

Eclipse에서 코드 수정 후 저장시 자동으로 코딩 컨벤션 룰이 적용되게 하는 방법

  1. Eclipse Java Formatter 적용작업이 선행되어있어야 한다.
  2. Eclipse에서 다음 설정으로 이동
    1. Preference > Java > Editor > Save Actions
  3. Save Actions 설정
    1. Perform the selected actions on save 체크
    2. Format source code 체크
      1. Format all lines
        1. 저장시 수정된 파일 전체라인에 대해서 코딩 컨벤션을 적용
      2. Format edited lines
        1. 저장시 수정된 부분에 대해서 코딩 컨벤션을 적용
    3. Organize imports 체크
  4. Apply > OK



Posted by leechwin
,

Proxy 를 쓰고있는 환경에서 Eclipse Update Site 와 Eclipse Marketplace 등에 접속이 안되는 경우 다음과 같이 설정을 한다.


  • Preferences > Network Connections
    • Active Provider 를 Manual 로 설정
    • HTTP/HTTPS Proxy 설정
    • SOCKS 에 대한 설정은 하지 않는다.
  • 이후 Eclipse 를 재시작하면 된다.


Posted by leechwin
,

Eclipse Mars (4.5.1)을 다운 받고 나서 Java 개발 셋팅을 하던중 자주 사용하던 dejavu sans mono 폰트가 기본으로 깔려 있지 않은 것을 확인했다.

Dejavu Sans Mono 폰트가 기존에 쓰던 기본 폰트중 쓸만해서 쓰다보니 적응되서 다른 폰트는 어색하기에, 해당 폰트를 다운로드 받아서 설치해보도록 하자.

  • 자신이 원하는 폰트를 다운로드 받는다.
    • Dejavu Sans Mono 폰트의 경우 아래의 링크에서 다운 받을 수 있다. 설치 원하는 폰트를 다운로드 받도록 하자. 일부 폰트는 설치 및 적용까지 된다.
  • 다운 로드 받은 폰트를 압축을 푼다.
  • Eclipse 에서 font 설정을 위해 Preferences 설정으로 이동
    • General > Appearance > Colors and Fonts > Java > Java Editor Font
  • Font 설정에서 좌측 하단의 다른 글꼴 표시를 클릭
    • 일부 폰트는 압축 해제 및 설치까지 되는데, 설치까지 자동으로 되었다면 아래 글꼴 검색에서 바로 검색되어 바로 적용이 가능하다.
  • 다운로드 받은 폰트파일을 다음 경로로 복사한다.
    • Windows 10의 경우 제어판\모양 및 개인 설정\글꼴
  • 폰트 파일을 복사한 뒤에 해당폰트를 클릭하여 원하는 폰트를 선택하고 표시 버튼을 클릭한다.
  • Eclipse 의 Font 설정 창을 다시 돌아가서 해당 폰트를 검색하면 검색되는것을 볼 수 있고, 바로 선택하고 확인을 하면 적용이 되는것을 볼 수 있다.


Posted by leechwin
,

Eclipse 에서 JSDT 와 같은 프로젝트를 import 한 경우 다음과 같은 에러가 발생하는 경우가 있다.


"An API baseline has not been set for the current workspace"


이 에러는 Eclipse Plug-in Development 와 JSDT 등과 같은 플랫폼코드단의 버그로 보인다.


위와 같은 에러가 발생 할 경우 다음과 같이 Preference 설정을 바꿔준다.

  1. Windows > Preferences > Plug-in Development > API Baselines > Options > Missing API baseline\

  2. Error 로 설정된 부분을 Ignore 로 변경해준다.



Reference: http://exploreeclipse.blogspot.kr/2014/01/eclipse-error-api-baseline-has-not-been.html

Posted by leechwin
,

Eclipse 에서 JAXB 를 사용한 프로젝트에서 다음과 같은 에러가 발생하는 경우가 있다.


"The currently selected JAXB library provider is invalid"


위와 같은 에러가 발생 할 경우 다음과 같이 프로젝트 설정을 바꿔준다.

  1. JAXB 프로젝트를 클릭 후 마우스 우클릭으로 Properties 설정에 들어간다.

  2. Project Facets 를 클릭하고 JAXB 항목의 버전을 변경

    1. Java SE 6 이면 2.1 버전

    2. Java SE 7 이면 2.2 버전

  3. 버전을 바꾸면 "Further configuration available" 이라는 링크가 생기는데 이곳을 클릭하면 설정이 나타난다.

    1. Platform 설정은 Generic JAXB 2.X

    2. JAXB implementation 의 Type 은 JRE 로 설정하고 OK





Reference: http://stackoverflow.com/questions/7039493/jaxb-project-in-eclipse-indigo

Posted by leechwin
,

 Eclipse Fragment 프로젝트는 기존에 존재하는 plugin 에 대한 패치나 번들처리등에 이용이 된다.


 하지만 기존에 존재하는 eclipse core framework 의 일부 jar 나 plugin 에 대해서 fragment 가 제대로 동작 하지 않는 경우가 있다.

 이에 대한 해결방법에 대해 알아보자.

 아래부터는 원본 jar 나 plugin 을 Host Plugin 이라 지칭하고, fragment plugin 을 Patch plugin 이라 지칭


  • Host Plugin Setting
    • plugin.xml 설정
      • Overview
        • version 이 중복되지 않도록 "_patch" 등의 이름으로 수정
      • Runtime > Classpath
        • patch.jar 라는 이름을 추가하고, patch.jar 가 "." 위로 오도록 순서수정
      • Build > Runtime Information
        • patch.jar 가 있다면 삭제하고 "." 만 나오게 수정
        • Folder 는 src/ 가 나오게 수정
      • MANIFEST.MF
        • Eclipse-ExtensibleAPI: true 를 기술
        • MANIFEST.MF 파일 예제
          • Bundle-Version: 1.3.1.v201401291437_patch
            ...skip...
            Eclipse-ExtensibleAPI: true
            Bundle-ClassPath: patch.jar, 

             . 

    • build.properties 파일 예제
      •  jars.compile.order = .

        bin.includes = .,\
                       META-INF/,\
                       plugin.properties,\
                       plugin.xml,\
                       default.properties,\
                       .options
        javacSource=1.5
        javacTarget=1.5
        source.. = src/
        output.. = bin/


  • Patch Plugin Setting
    • MANIFEST.MF 
      • Overview
        • Host Plug-in 선택 
      • Runtime > Classpath
        • patch.jar 라는 이름을 추가하고, patch.jar 가 "." 위로 오도록 순서수정
      • Build > Runtime Information
        • patch.jar 가 있다면 삭제하고 "." 만 나오게 수정
        • Folder 는 src/ 가 나오게 수정
      • MANIFEST.MF
        • Eclipse-PatchFragment: true 를 기술
        • MANIFEST.MF 파일 예제
          • Eclipse-PatchFragment: true

            Bundle-ClassPath: patch.jar,
             .

      • build.properties 파일 예제
        • bin.includes = META-INF/,\

          patch.jar

          jars.compile.order = patch.jar

          source.patch.jar = src/

  • Feature 프로젝트에 Patch Plugin 이 포함된 Feature Dependency 기술
    • a.plugin 을 패치한다면 해당 plugin 에 버전이 xxx_patch 등으로 바뀌었을것이다.
    • 이후 a.plugin 을 포함하고있는 abc.feature plugin 에 해당 내용을 수정해야되는데 수정하는 방법은 2가지가 있다.
      • abc.feature plugin 을 통째로 include 하는법
      • abc.feature pulgin 에 기술된 plugin 들을 전부 include 하는법
    • 위의 내용을 feature 프로젝트를 하나 생성하여 plugin.xml 에 Feature 혹은 Plugin 탭에서 기술한다.  
    • Eclipse Framework 환경에서 Dependecy 확인하는법 
      • ../eclipse/feature 폴더로 이동
      • 다음 명령어 수행
        • $ grep -r pluginName .



Posted by leechwin
,

 Eclipse 에서 File Decorator 로 org.eclipse.ui.decorators extension point 를 확장하고 ILightweightLabelDecorator 을 implements 한 경우 파일에 Warning 이나 Error 가 발생하여도 Package Explorer 에서 Marker 가 보이지 않는 경우가 있다.


 이 경우 ILightweightLabelDecorator 인터페이스 구현 부분을 ILabelDecorator 인터페이스로 바꾸어 재구현하면 위의 현상이 나타나지 않는데, ILabelDecorator 는 ILightweightLabelDecorator 보다 퍼포먼스가 많이 좋지 않기 때문에 완전한 해결책이라고 볼수가 없다.


 이런 현상은 ILightweightLabelDecorator 버그로 bugzilla 에 보고 되어있기도 하다.


 이 경우 Preference 의  File Icon Based On Content Analysis 옵션을 체크 해제하면 문제가 해결되는 경우가 있는데 옵션해제는 다음과 같은 경로로 하면 마커가 제대로 나오는 경우가 있다.

  • Eclipse > Window > Preferences > Genaral > Appearance > Label Decorations > "File Icon Based On Content Analysis" 부분을 해제

File Icon Based On Content Analysis 의 구현은 다음과 같은데 ILightweightLabelDecorator 인터페이스를 구현하고 있는데 이부분에 버그가 있는것 같다.

  • File Icon Based On Content Analysis
    • org.eclipse.ui.ContentTypeDecorator 의 확장점으로 구현
    • public class ContentTypeDecorator implements ILightweightLabelDecorator  
      • ILightweightLabelDecorator 을 implement 하고
    • 파일의 Decoration 으로 파일기본 ContentDescription 이 있다면 이정보를 바탕으로 Decorate


프로그래밍적으로 eclipse 의 Preference 에서 이부분을 uncheck 된 상태로 시작 하려면 다음과 같이 코드를 수정한다.

  • org.eclipse.ui.startup extension point 를 확장하여 워크벤치가 로딩될때 무조건 호출되도록 StartUp class 를 생성
  • 위에서 생성한 StartUp class 에서 다음과 같이 File Icon Based On Content Analysis 부분이 uncheck 되도록 수정한다.
public void earlyStartup() {
    DecoratorDefinition[] definitions = WorkbenchPlugin.getDefault().getDecoratorManager().getAllDecoratorDefinitions();
    for (DecoratorDefinition decoratorDef : definitions) {
        if (decoratorDef.getId().equalsIgnoreCase("org.eclipse.ui.ContentTypeDecorator")) {
            decoratorDef.setEnabled(false);
            break;
        }
    }
}




Posted by leechwin
,