반응형

scp는 리룩스에서 사용되는 서버로서버로 파일 복사및 전달하는 명령어이다.

사용법:

1. 원격 서버 -> 로컬 서버

scp -options 계정@원격서버주소:파일경로 전송받을위치

2.로컬 서버 -> 원격서버

scp -options 전송파일위치 계정@원격서버주소:전송받을위치


options:

-P : 포트번호

-p : 파일 권한 유지

-r : 하위 디렉토리 및 파일 모두 복사.


*대문자 P와 소문자 p 옵션이 따로 있으니 주의하고 사용!


ex) a계정으로 b.tistory.com서버 /home/c라는 폴더에 내 컴퓨터 Desktop에 있는 파일 example.txt를 전송할때

scp /Users/username/Desktop/example.txt a@b.tistory.com:/home/c

반응형

'Linux > 명령어' 카테고리의 다른 글

iconv 명령어  (0) 2015.12.29
split 명령어  (0) 2015.12.23
반응형

JAVA에는 L&F(Look & Feel)이라는 것을 이용하여 GUI의 모양을 결정할 수 있다.

L&F를 사용하여 맥에서 window에서 실행되는 JAVA GUI처럼 MAC에서 실행되는 GUI를 바꿀 수 있다.


아래와 같은 코드를 프로그램에 넣으면 MAC에서 실행되는 자바 SWING 프로그램의 GUI를 windows 환경처럼 바꿀 수 있다.

try{

UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

}catch(Exception e){

e.printStackTrace();

}


위 사진은 MAC에서 실행한 예제이다.


위 사진은 L&F를 변경하여 MAC에서 실행한 예제이다.


내가 이 L&F를 사용하게 된 이유는 Mac에서 실행한 자바 프로그램에서 아직 원인은 모르지만 Button의 색을 바꿀때 바뀌지 않는 경우가 발생할 때가 있다.

하지만 windows에서는 같은 프로그램이지만 Button의 색이 잘 변경되어서 이 문제를 해결하기 위해 구글에서 검색하다보니 L&F라는 것을 알게되어 Button색을 바꿔줄 수 있게 되었다.


Sun's JRE에서 제공되는 L&F의 종류

Sun's JRE provides the following L&Fs:

  1. CrossPlatformLookAndFeel—this is the "Java L&F" (also called "Metal") that looks the same on all platforms. It is part of the Java API (javax.swing.plaf.metal) and is the default that will be used if you do nothing in your code to set a different L&F.

  2. SystemLookAndFeel—here, the application uses the L&F that is native to the system it is running on. The System L&F is determined at runtime, where the application asks the system to return the name of the appropriate L&F.

  3. Synth—the basis for creating your own look and feel with an XML file.

  4. Multiplexing— a way to have the UI methods delegate to a number of different look and feel implementations at the same time.

* 참고 사이트

https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

반응형
반응형

재귀 함수를 이용해 한번에 File[]에 모든 파일들을 넣는 방법도 있지만

난 좀 더 쉽게 파일을 찾아 디렉토리면 다시 폴더로 들어가고 아니면 파일을 여는 재귀함수 방법으로 구현하였다.

public static void test(File f){

File f = new File("파일(폴더) 경로");

if(f.isDirectory()){        //f가 디렉토리인지 확인

File []arrFS=f.listFiles();        //디렉토리이니까 파일 리스트를 받아온다.

for(int i = 0 ; i<arrFS.length;i++){        //파일 수 만큼 함수 다시 실행.

test(arrFS[i]);

}

}

else{

 //do somethings

}

}

이렇게 구현하면 매우 쉽게 폴더안의 내용들을 읽어 올 수 있다.

반응형
반응형

CentOs에 root외 ssh접속 유저 계정을 만드는 방법

Centos 6.7 (Final) version


생성 방법

1.  useradd [options] LOGIN

   ex) useradd black  -> black이라는 유저 생성

         ID에 생성할 유저 ID를 넣으면 된다.

         /home/ 폴더에 유저 폴더 생성이 된다.

options :

     -b, --base-dir BASE_DIR                          base directory for the home directory of the new account

     -c, --comment COMMENT                      GECOS field of the new account

     -d, --home-dir HOME_DIR                       home directory of the new account

     -D, --defaults                                             print or change default useradd configuration

     -e, --expiredate EXPIRE_DATE                 expiration date of the new account

     -f, --inactive INACTIVE                               password inactivity period of the new account

     -g, --gid GROUP                                          name or ID of the primary group of the new account

     -G, --groups GROUPS                                list of supplementary groups of the new account

     -h, --help                                                    display this help message and exit

     -k, --skel SKEL_DIR                                   use this alternative skeleton directory

     -K, --key KEY=VALUE                                override /etc/login.defs defaults

     -l, --no-log-init                                          do not add the user to the lastlog and faillog databases

     -m, --create-home                                   create the user's home directory

     -M, --no-create-home                              do not create the user's home directory

     -N, --no-user-group                                 do not create a group with the same name as the user

     -o, --non-unique                                      allow to create users with duplicate (non-unique) UID

     -p, --password PASSWORD                    encrypted password of the new account

     -r, --system                                               create a system account

     -s, --shell SHELL                                       login shell of the new account

     -u, --uid UID                                             user ID of the new account

     -U, --user-group                                       create a group with the same name as the user

     -Z, --selinux-user SEUSER                        use a specific SEUSER for the SELinux user mapping

2. passwd ID

    ex) passwd black -> black 유저 비밀번호 설정.

         생성한 유저 ID의 비밀번호를 설정한다.

         비밀번호가 짧고 숫자나 문자로만 되어있으면

         잘못된 암호: 너무 짧습니다  

         잘못된 암호: 너무 간단함

         라는 메세지가 출력되지만 무시하고 설정하면 비밀번호 설정이 된다.(비추)

삭제 방법

1. userdel [options] LOGIN

    ex) userdel black -> black 유저 삭제

          /home/경로에 생성된 유저 폴더는 삭제가 안된다.

options :

     -f, --force                                           force removal of files, even if not owned by user

     -h, --help                                           display this help message and exit

     -r, --remove                                      remove home directory and mail spool

     -Z, --selinux-user                              remove SELinux user from SELinux user mapping

반응형

'Linux > CentOs' 카테고리의 다른 글

CentOS 버전 확인  (0) 2016.01.18
반응형

평상시에는 LayoutManager를 이용하여 UI의 위치를 잡고 사용하지만

가끔 setbounds을 이용해 UI 위치를 절대값을 사용하여 위치하는 경우가 있다.

이 함수를 사용하면 편하게 원하는 위치에 UI위치를 설정할 수 있다.

하지만 이 함수를 쓰면 위치와 크기가 고정이 되어 프로그램 크기를 조정했을때 변하지 않고 항상 그 위치에 고정되어있다.

이 상태를 해결하기위해 JAVA는 ComponentListener라는 리스너를 지원해준다.

이 리스너에서 사용할 수 있는 함수는 4가지가 있다.

void componentHidden (ComponentEvent e) 
컴퍼넌트가 불가시가 되면(자) 불려 갑니다.
void componentMoved (ComponentEvent e) 
컴퍼넌트의 위치가 바뀌면(자) 불려 갑니다.
void componentResized (ComponentEvent e) 
컴퍼넌트의 사이즈가 바뀌면(자) 불려 갑니다.
void componentShown (ComponentEvent e) 
컴퍼넌트가 가시가 되면(자) 불려 갑니다.

저 함수들 중 componentResized() 함수를 이용하여 컴포넌트 크기가 변할 때 setbounds를 다시 실행시켜주면

 setbounds를 이용한 자신만의 LayoutManager를 사용한 것과 같은 효과를 낼 수 있다.

반응형

'프로그래밍 > JAVA' 카테고리의 다른 글

[팁] application bundle 위치  (0) 2015.12.08
JAVA L&F(Look & Feel)  (0) 2015.12.05
Java 폴더안에 내용 모두 읽기  (4) 2015.12.03
JAVA Jtable cell not editable  (0) 2015.12.02
JAVA Jtable 자동 키입력 막기  (0) 2015.12.02
반응형

JTable 셀 자체를 아예 수정이 안되게하는 방법이 있는데 

Table.setEditable(false)를 이용하면 JTable 수정이 불가능 한 상태로 변한다.

이 함수를 사용하면 JTable 셀 선택도 불가능하게 된다.

선택은 가능하게 하면서 수정을 막는 방법은 아래와 같다.

Table.setModel(new DefaultTableModel(new Object[][][] {}, new String[] { "셀1","셀2","셀3" }){

public boolean isCellEditable(int row, int column) {

      //all cells false

      return false;

    }

});

반응형
반응형

자바에서 JTable에 단축키를 설정하여 KeyListener를 사용할 때 JTable 기본 옵션으로 키보드 특수키 외 다른 키를 입력하였을 때 수정이 바로 되는 경우가 있다.

이렇게 되면 JTable안 내용이 변경이 되기 때문에 매우 불편한 상황이 발생할 수도 있다.

그래서 JTable에 키를 입력했을때 내용수정이 안되게 하는 함수가 있다.

Table.putClientProperty("JTable.autoStartsEdit", Boolean.FALSE);

이 함수를 쓰면 JTable 셀이 선택되어있을때 키를 입력해도 자동으로 입력이 되지 않고 더블클릭으로 수정이 가능하게 해야 내용수정이 가능하게 된다.

반응형

+ Recent posts