검색결과 리스트
전체에 해당되는 글 1012건
- 2013.04.23 [Node.js] Node.js tutorial
- 2013.04.22 [.Net] TransactedInstaller
- 2013.04.22 [Scala] 스칼라 프로그래밍
- 2013.04.20 [.Net] Windows Service Current Directory
- 2013.04.20 [.Net] Changing Start Mode of a Windows Service
- 2013.04.19 [.Net] Mutex 클래스
- 2013.04.18 [.Net] ServiceController
- 2013.04.17 [Visual Studio] Visual Studio 설치 관리자
- 2013.04.17 [.Net] Windows 서비스 만들기
- 2013.04.16 [Windows] .exe 아이콘이 안보일때 (.exe icon not showing)
- 2013.04.15 [Git] Tortoisegit
- 2013.04.12 [.Net] HTTP POST/WebClient (C#) and CSV formated string
- 2013.04.11 [Eclipse] publishing failed with multiple errors eclipse
- 2013.04.10 [Eclipse] Working Set 만들기
- 2013.04.07 [Eclipse] java 프로젝트에서 jar 파일 포함시키기
- 2013.04.07 [Java] jar 파일 실행 시키기
- 2013.04.05 [Spring] Spring Tiles
- 2013.04.05 [Eclipse] svn ignore 하기
- 2013.04.04 [Tomcat] Tomcat 5.5. JNDI 설정
- 2013.04.03 [Linux] Shell Script
- 2013.04.03 [Eclipse] Link With Editor
- 2013.04.03 [Spring] 스프링 버전 확인하기
- 2013.04.03 [Eclipse] 인코딩 에러 Some characters cannot be mapped using "ISO-8859-1" character encoding.
- 2013.04.02 [Eclipse] eclipse.ini 설정
- 2013.04.02 [Jeus] Jeus5 스펙
- 2013.04.02 [Java] JDK Download
- 2013.04.01 [Git] Git Tutorial
- 2013.03.30 [Git] SourceTree (windows)
- 2013.03.14 [VC++] Design Specifications and Guidelines - Visual Design
- 2013.03.13 [WinForm] OpenFileDialog
글
'JavaScript > NodeJS' 카테고리의 다른 글
[Node.js] Render ejs with express (0) | 2014.01.13 |
---|---|
[Node.js] Express - API 가이드 문서 (0) | 2014.01.13 |
[Node.js] IntelliJ에서 Node 사용시 [ReferenceError: Process is not defined] 발생시 대처 (0) | 2014.01.10 |
[Node.js] Node download (0) | 2014.01.10 |
[Node.js] Node.js 한글 페이지 (0) | 2012.02.09 |
트랙백
댓글
글
TransactedInstaller 를 사용하면은 Installutil.exe(설치 관리자 도구)의 구현과 유사한 구현을 제공 할수 있다.
ArrayList myOptions = new ArrayList();
String myOption;
bool toUnInstall = false;
bool toPrintHelp = false;
TransactedInstaller myTransactedInstaller = new TransactedInstaller();
AssemblyInstaller myAssemblyInstaller;
InstallContext myInstallContext;
try
{
for(int i = 0; i < args.Length; i++)
{
// Process the arguments.
if(args[i].StartsWith("/") || args[i].StartsWith("-"))
{
myOption = args[i].Substring(1);
// Determine whether the option is to 'uninstall' an assembly.
if(String.Compare(myOption, "u", true) == 0 ||
String.Compare(myOption, "uninstall", true) == 0)
{
toUnInstall = true;
continue;
}
// Determine whether the option is for printing help information.
if(String.Compare(myOption, "?", true) == 0 ||
String.Compare(myOption, "help", true) == 0)
{
toPrintHelp = true;
continue;
}
// Add the option encountered to the list of all options
// encountered for the current assembly.
myOptions.Add(myOption);
}
else
{
// Determine whether the assembly file exists.
if(!File.Exists(args[i]))
{
// If assembly file doesn't exist then print error.
Console.WriteLine("\nError : {0} - Assembly file doesn't exist.",
args[i]);
return;
}
// Create a instance of 'AssemblyInstaller' that installs the given assembly.
myAssemblyInstaller =
new AssemblyInstaller(args[i],
(string[]) myOptions.ToArray(typeof(string)));
// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Add(myAssemblyInstaller);
}
}
// If user requested help or didn't provide any assemblies to install
// then print help message.
if(toPrintHelp || myTransactedInstaller.Installers.Count == 0)
{
PrintHelpMessage();
return;
}
// Create a instance of 'InstallContext' with the options specified.
myInstallContext =
new InstallContext("Install.log",
(string[]) myOptions.ToArray(typeof(string)));
myTransactedInstaller.Context = myInstallContext;
// Install or Uninstall an assembly depending on the option provided.
if(!toUnInstall)
myTransactedInstaller.Install(new Hashtable());
else
myTransactedInstaller.Uninstall(null);
}
catch(Exception e)
{
Console.WriteLine("\nException raised : {0}", e.Message);
}
참고 : http://www.devpia.com/Maeul/Contents/Detail.aspx?BoardID=18&MAEULNO=8&no=1971&page=2
MFC C++쓸땐 Self 서비스 등록 코드를 썼는데
C#에서는 InstallUtil.exe를 써야 하는데
InstallUtil.exe이 패스에 안걸려 있으면 찾아서 써야 하니 귀찮기도 하구 해서
아침에 삽질 삽질 하다가.. 거의 포기하려는 순간에 찾았네요.
서비스로 만드는 법은 뭐 간단하니 아실거구.
서비스 인스톨러도 추가해 놓으심 되구요..
그 다음에 Main을 아래와 같이 넣어서 고쳐 쓰심 됩니다.
/install 과 /uninstall 로 서비스에 넣었다 뺏다 합니다.
ServiceMain은 내가 만든 서비스 실행 클래스 일 뿐이구요
추가 하셔서 일반에서 서비스를 선택하시면 됩니다.
[STAThread]
static void Main(string[] args)
{
if (args.Length == 1)
{
try
{
using (TransactedInstaller ti = new TransactedInstaller())
{
using (ProjectInstaller pi = new ProjectInstaller())
{
ti.Installers.Add(pi);string[] cmdline = { string.Format("/assemblypath={0}", System.Reflection.Assembly.GetExecutingAssembly().Location) };
pi.Context = new InstallContext(null, cmdline);
if (args[0].ToLower() == "/install")
pi.Install(new Hashtable());
else if (args[0].ToLower() == "/uninstall")
pi.Uninstall(null);
else
throw new Exception("Invalid command line");
}
}
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
}
}
else
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new ServiceMain() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
}
'.Net > .Net' 카테고리의 다른 글
[.Net] 런타임에서 어셈블리를 찾는 방법 (0) | 2013.05.20 |
---|---|
[.Net] 닷넷프레임워크 버전 확인 (0) | 2013.05.10 |
[.Net] Windows Service Current Directory (0) | 2013.04.20 |
[.Net] Changing Start Mode of a Windows Service (0) | 2013.04.20 |
[.Net] Mutex 클래스 (0) | 2013.04.19 |
트랙백
댓글
글
홈페이지 : http://www.scala-lang.org/
대부분의 스칼라 관련 문서들에서 스칼라와 자바의 연관성을 '너무 바빠서 다른 언어를 따로 배울 시간이 없는 자바 프로그래머를 위한' 이라는 표현을 사용하여 나타낼 정도로 비슷한 부분이 많이 나타난다.
위키에서 가져온 설명이다.
생산성 향상을 위해서 좋을 듯 한다. 다만 프로젝트를 했을때 나 혼자 사용해서는 도리어 전체 생상성 저하를 가져올듯.
세상에 좋은 툴과 언어와 프로그램이 있지만 결국 도입비용과 교육비용을 같이 비교해 보아야 실제 적용가능 할 듯 하다.
'Java > Scala' 카테고리의 다른 글
[Scala] 자바프로그래머를 위한 Scala (0) | 2013.05.09 |
---|
트랙백
댓글
글
윈도우즈 서비스에서
System.Environment.CurrentDirectory 을 호출하면 "C:\Windows\System32"를 카리킨다.
그럴때 두가지 방법이 있다.
1. System.Windows.Forms 을 참조하고 System.Windows.Forms.Application.StartupPath을 호출
2. System.Reflection.Assembly.GetEntryAssembly().Location
'.Net > .Net' 카테고리의 다른 글
[.Net] 닷넷프레임워크 버전 확인 (0) | 2013.05.10 |
---|---|
[.Net] TransactedInstaller (0) | 2013.04.22 |
[.Net] Changing Start Mode of a Windows Service (0) | 2013.04.20 |
[.Net] Mutex 클래스 (0) | 2013.04.19 |
[.Net] ServiceController (0) | 2013.04.18 |
트랙백
댓글
글
참고 : http://peterkellyonline.blogspot.kr/2011/04/configuring-windows-service.html
결국 어플리 케이션을 디테일하게 컨트롤 할려면 .Net에서 WinApi를 호출해야 한다는 결론
위 Url참고 하여 GetStartMode메소드 추가
public static class ServiceHelper
{
[DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern Boolean ChangeServiceConfig(
IntPtr hService,
UInt32 nServiceType,
UInt32 nStartType,
UInt32 nErrorControl,
String lpBinaryPathName,
String lpLoadOrderGroup,
IntPtr lpdwTagId,
[In] char[] lpDependencies,
String lpServiceStartName,
String lpPassword,
String lpDisplayName);[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern IntPtr OpenService(
IntPtr hSCManager, string lpServiceName, uint dwDesiredAccess);[DllImport("advapi32.dll", EntryPoint = "OpenSCManagerW", ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr OpenSCManager(
string machineName, string databaseName, uint dwAccess);[DllImport("advapi32.dll", EntryPoint = "CloseServiceHandle")]
public static extern int CloseServiceHandle(IntPtr hSCObject);[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
public static extern Boolean QueryServiceConfig(IntPtr hService, IntPtr intPtrQueryConfig, UInt32 cbBufSize, out UInt32 pcbBytesNeeded);[DllImport( "advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "QueryServiceConfig2W" )]
public static extern Boolean QueryServiceConfig2( IntPtr hService, UInt32 dwInfoLevel, IntPtr buffer, UInt32 cbBufSize, out UInt32 pcbBytesNeeded );
private const uint SERVICE_NO_CHANGE = 0xFFFFFFFF;
private const uint SERVICE_QUERY_CONFIG = 0x00000001;
private const uint SERVICE_CHANGE_CONFIG = 0x00000002;
private const uint SC_MANAGER_ALL_ACCESS = 0x000F003F;[StructLayout(LayoutKind.Sequential)]
public class QUERY_SERVICE_CONFIG
{
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]
public UInt32 dwServiceType;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]
public UInt32 dwStartType;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]
public UInt32 dwErrorControl;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public String lpBinaryPathName;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public String lpLoadOrderGroup;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]
public UInt32 dwTagID;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public String lpDependencies;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public String lpServiceStartName;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public String lpDisplayName;
};public static void ChangeStartMode(ServiceController svc, ServiceStartMode mode)
{
var scManagerHandle = OpenSCManager(null, null, SC_MANAGER_ALL_ACCESS);
if (scManagerHandle == IntPtr.Zero)
{
throw new ExternalException("Open Service Manager Error");
}var serviceHandle = OpenService(
scManagerHandle,
svc.ServiceName,
SERVICE_QUERY_CONFIG | SERVICE_CHANGE_CONFIG);if (serviceHandle == IntPtr.Zero)
{
throw new ExternalException("Open Service Error");
}var result = ChangeServiceConfig(
serviceHandle,
SERVICE_NO_CHANGE,
(uint)mode,
SERVICE_NO_CHANGE,
null,
null,
IntPtr.Zero,
null,
null,
null,
null);if (result == false)
{
int nError = Marshal.GetLastWin32Error();
var win32Exception = new Win32Exception(nError);
throw new ExternalException("Could not change service start type: "
+ win32Exception.Message);
}CloseServiceHandle(serviceHandle);
CloseServiceHandle(scManagerHandle);
}/// <summary>
/// Automatic = 2, Manual = 3, Disabled = 4
/// </summary>
/// <param name="svc"></param>
/// <returns></returns>
public static uint GetStartMode(ServiceController svc)
{
var scManagerHandle = OpenSCManager(null, null, SC_MANAGER_ALL_ACCESS);
if (scManagerHandle == IntPtr.Zero)
{
throw new ExternalException("Open Service Manager Error");
}var serviceHandle = OpenService(
scManagerHandle,
svc.ServiceName,
SERVICE_QUERY_CONFIG);if (serviceHandle == IntPtr.Zero)
{
throw new ExternalException("Open Service Error");
}UInt32 dwBytesNeeded = 0;
IntPtr ptr = Marshal.AllocHGlobal(4096);// Allocate memory for struct.bool result = QueryServiceConfig(
serviceHandle,
ptr,
4096,
out dwBytesNeeded);QUERY_SERVICE_CONFIG qUERY_SERVICE_CONFIG = new QUERY_SERVICE_CONFIG();
Marshal.PtrToStructure(ptr, qUERY_SERVICE_CONFIG);// Copy;
Marshal.FreeHGlobal(ptr);if (result == false)
{
int nError = Marshal.GetLastWin32Error();
var win32Exception = new Win32Exception(nError);
throw new ExternalException("Could not QueryServiceConfig : "
+ win32Exception.Message);
}CloseServiceHandle(serviceHandle);
CloseServiceHandle(scManagerHandle);return qUERY_SERVICE_CONFIG.dwStartType;
}
}
var svc = new ServiceController("BITS");
ServiceHelper.ChangeStartMode(svc, ServiceStartMode.Automatic);// You can then Start the service if necessary.
if (svc.Status != ServiceControllerStatus.Running)
{
svc.Start();
}// And of course you should close the service when no longer needed
svc.Close();
'.Net > .Net' 카테고리의 다른 글
[.Net] TransactedInstaller (0) | 2013.04.22 |
---|---|
[.Net] Windows Service Current Directory (0) | 2013.04.20 |
[.Net] Mutex 클래스 (0) | 2013.04.19 |
[.Net] ServiceController (0) | 2013.04.18 |
[.Net] Windows 서비스 만들기 (0) | 2013.04.17 |
트랙백
댓글
글
Mutex : http://msdn.microsoft.com/ko-kr/library/01985e8f(v=vs.100).aspx
WaitHandle : http://msdn.microsoft.com/ko-kr/library/system.threading.waithandle(v=vs.100).aspx
'.Net > .Net' 카테고리의 다른 글
[.Net] Windows Service Current Directory (0) | 2013.04.20 |
---|---|
[.Net] Changing Start Mode of a Windows Service (0) | 2013.04.20 |
[.Net] ServiceController (0) | 2013.04.18 |
[.Net] Windows 서비스 만들기 (0) | 2013.04.17 |
[.Net] HTTP POST/WebClient (C#) and CSV formated string (0) | 2013.04.12 |
트랙백
댓글
글
'.Net > .Net' 카테고리의 다른 글
[.Net] Changing Start Mode of a Windows Service (0) | 2013.04.20 |
---|---|
[.Net] Mutex 클래스 (0) | 2013.04.19 |
[.Net] Windows 서비스 만들기 (0) | 2013.04.17 |
[.Net] HTTP POST/WebClient (C#) and CSV formated string (0) | 2013.04.12 |
[.Net] RSA 암호화 (0) | 2013.03.13 |
트랙백
댓글
글
Visual Studio 설치관리자 배포 : http://msdn.microsoft.com/ko-kr/library/vstudio/2kt85ked(v=vs.100).aspx
사용자 지정 작업 만들기 : http://msdn.microsoft.com/ko-kr/library/vstudio/d9k65z2d(v=vs.100).aspx
참고 : http://styletigger.tistory.com/21
추가 : http://msdn.microsoft.com/ko-kr/library/vstudio/d9k65z2d(v=vs.100).aspx
C++로 만드는 방법 : http://www.codeproject.com/Articles/335516/Custom-Action-in-Visual-Studio-setup-projects
http://msdn.microsoft.com/en-us/library/windows/desktop/aa370134(v=vs.85).aspx
UINT __stdcall MyCustomAction(MSIHANDLE hInstall)
{
TCHAR* szValueBuf = NULL;
DWORD cchValueBuf = 0;
UINT uiStat = MsiGetProperty(hInstall, TEXT("MyProperty"), TEXT(""), &cchValueBuf);
//cchValueBuf now contains the size of the property's string, without null termination
if (ERROR_MORE_DATA == uiStat)
{
++cchValueBuf; // add 1 for null termination
szValueBuf = new TCHAR[cchValueBuf];
if (szValueBuf)
{
uiStat = MsiGetProperty(hInstall, TEXT("MyProperty"), szValueBuf, &cchValueBuf);
}
}
if (ERROR_SUCCESS != uiStat)
{
if (szValueBuf != NULL)
delete[] szValueBuf;
return ERROR_INSTALL_FAILURE;
}// custom action uses MyProperty
// ...delete[] szValueBuf;
return ERROR_SUCCESS;
}
'IDE/Tool > Visual Studio' 카테고리의 다른 글
[Visual Studio] Remote Debugger (0) | 2013.07.03 |
---|---|
[Visual Studio] Advanced Debugging in Visual Studio (0) | 2013.05.28 |
[Visual Stdio 2010] 공백 표시 (0) | 2013.03.08 |
[Visual Studio] Visual Studio Automation Object Model (0) | 2013.02.01 |
[Visual Studio 2010] Visual Studio Automatically using (0) | 2012.12.18 |
트랙백
댓글
글
* 연습 : 구성 요소 디자이너에서 Windows 서비스 응용 프로그램 만들기
링크 : http://msdn.microsoft.com/ko-kr/library/zt39148a(VS.80).aspx
* 방법 : Windows 서비스 응용 프로그램 디버깅
링크 : http://msdn.microsoft.com/ko-kr/library/7a50syb3(VS.80).aspx
'.Net > .Net' 카테고리의 다른 글
[.Net] Mutex 클래스 (0) | 2013.04.19 |
---|---|
[.Net] ServiceController (0) | 2013.04.18 |
[.Net] HTTP POST/WebClient (C#) and CSV formated string (0) | 2013.04.12 |
[.Net] RSA 암호화 (0) | 2013.03.13 |
[.Net] EXE를 포함한 외부 DLL을 같이 배포하기 (0) | 2013.02.19 |
트랙백
댓글
글
링크 : http://forums.techguy.org/windows-7/977270-icons-not-displaying-properly.html
1. C:\Users\[사용자]\AppData\Local\IconCache.db를 삭제한다. (혹 모르니 백업해두면 좋다.)
2. 작업관리자에서 explorer.exe를 킬한다.
3. 명령프롬프트에서 explorer.exe를 실행시킨다.
'OS > Windows' 카테고리의 다른 글
[Windows] 원격데스크탑 포트 변경 (0) | 2014.06.05 |
---|---|
[Windows Service] Windows 쓸모없는 service 제거 (0) | 2013.05.29 |
[Windows] 프로그램을 서비스로 등록하는 방법 (0) | 2012.12.07 |
[Windows] 프로그램 글자가 깨질때 (0) | 2012.10.17 |
[Windows] Message (0) | 2012.07.30 |
트랙백
댓글
글
링크 : https://code.google.com/p/msysgit/downloads/list
링크 : http://code.google.com/p/tortoisegit/
링크 : http://kkamagui.tistory.com/751
Tortorise SVN을 유용하게 사용하고 있는데 같은 회사에서 Tortorise Git도 만들었네요.
첫번째 링크의 git(첫번째 다운로드)을 먼저 인스톨 한후
두번째 링크이 Toritoise Git을 설치한다.
세번째는 참고 사이트
'VCS > Git' 카테고리의 다른 글
[Git] Advanced Git (0) | 2013.11.27 |
---|---|
[Git] Git은 어떻게 동작하는가? (0) | 2013.11.26 |
[Git] Git Tutorial (0) | 2013.04.01 |
[Git] SourceTree (windows) (0) | 2013.03.30 |
[Git] A successful git branching model (1) | 2012.11.14 |
트랙백
댓글
글
링크 : http://technet.rapaport.com/Info/LotUpload/SampleCode/WebClient_string.aspx
string UploadCSVString = @"StockNumber,Shape,Weight,Color,Clarity" +
Environment.NewLine + "1234Eli,Round,2.0,F,VVS1"; //CSV forma
string URLAuth = "https://technet.rapaport.com/HTTP/Authenticate.aspx";
WebClient webClient = new WebClient();
NameValueCollection formData = new NameValueCollection();
formData["Username"] = "myUser";
formData["Password"] = "myPassword";
byte[] responseBytes = webClient.UploadValues(URLAuth, "POST", formData);
string ResultAuthTicket = Encoding.UTF8.GetString(responseBytes);
webClient.Dispose();
string URL = "http://technet.rapaport.com/HTTP/Upload/Upload.aspx?Method=string";
formData.Clear();
formData["ticket"] = ResultAuthTicket;
formData["UploadCSVString"] = UploadCSVString;
formData["ReplaceAll"] = "false";
responseBytes = webClient.UploadValues(URL, "POST", formData);
string Result = Encoding.UTF8.GetString(responseBytes);
'.Net > .Net' 카테고리의 다른 글
[.Net] ServiceController (0) | 2013.04.18 |
---|---|
[.Net] Windows 서비스 만들기 (0) | 2013.04.17 |
[.Net] RSA 암호화 (0) | 2013.03.13 |
[.Net] EXE를 포함한 외부 DLL을 같이 배포하기 (0) | 2013.02.19 |
[.Net] Castle DynamicProxy Tutorial (0) | 2013.01.23 |
트랙백
댓글
글
링크 : http://stackoverflow.com/questions/5618652/publishing-failed-with-multiple-errors-eclipse
Eclipse produces this message when a file in an Eclipse project is changed outside of Eclipse. To avoid it:
- a) Don't change files outside of Eclipse
- b) Refresh the workspace/project after changing files outside of Eclipse F5 or
- c) Enable
Window > Preferences > General > Workspace > Refresh Automatically
Note: in STS 2.8.1, it is "Refresh on Access"
'IDE/Tool > Eclipse' 카테고리의 다른 글
[Eclipse] Eclipse Indigo 3.7.1 + Tomcat 7.0.25 + 스프링 MVC + Maven 3.0.4 개발 환경 구축 (0) | 2013.07.19 |
---|---|
[Eclipse] Working Set 만들기 (0) | 2013.04.10 |
[Eclipse] java 프로젝트에서 jar 파일 포함시키기 (0) | 2013.04.07 |
[Eclipse] svn ignore 하기 (0) | 2013.04.05 |
[Eclipse] Link With Editor (0) | 2013.04.03 |
트랙백
댓글
글
참고 : http://okjsp.tistory.com/1165643034
이클립스에 프로젝트가 하나일때는 파일 검색할때 해당 프로젝트만 검색되기때문에 쉽게 됩니다.
그런데 프로젝트가 하나둘씩 늘어날때마다 검색 결과가가 여러 프로젝트에서 고르게 검색 될때가 있습니다.
이럴때는 이클립스 워킹셋을 만들어서 검색 범위를 줄일수 있습니다.
위외 같이 해당 워킹셋으로 검색 범위를 좁힐수 있습니다.
'IDE/Tool > Eclipse' 카테고리의 다른 글
[Eclipse] Eclipse Indigo 3.7.1 + Tomcat 7.0.25 + 스프링 MVC + Maven 3.0.4 개발 환경 구축 (0) | 2013.07.19 |
---|---|
[Eclipse] publishing failed with multiple errors eclipse (0) | 2013.04.11 |
[Eclipse] java 프로젝트에서 jar 파일 포함시키기 (0) | 2013.04.07 |
[Eclipse] svn ignore 하기 (0) | 2013.04.05 |
[Eclipse] Link With Editor (0) | 2013.04.03 |
트랙백
댓글
글
자바 프로그래머라고 하면 대부분 웹을 지칭하는 것 같습니다.
순수 자바 프로그래머 보기 쉽지 않네요.
저는 아직 한분도 뵙지 못했습니다.
이클립스에서 자바 프로젝트로 생성시 외부 jar 파일을 포함해야 하는 경우가 있습니다.
기존 서적 대부분은 콘솔 환경에서만 다루다 보면 막상 이클립스에서 할려면 막막하더군요.
그래서 정리해봤습니다.
1. TCPMON_TEST 프로젝트를 생성한다.
2. 프로젝트에 lib폴더를 생성한다 (꼭 lib 폴더 이름으로 생성할 필요없습니다.)
3. 외부 tcpmon-1.1.jar 파일을 넣는다.
4. 프로젝트 -> Properties -> Java Build Path -> Libraries -> Add JARs... -> [클릭]
5. 임포트한 tcpmon-1.1.jar 파일을 선택한다.
'IDE/Tool > Eclipse' 카테고리의 다른 글
[Eclipse] publishing failed with multiple errors eclipse (0) | 2013.04.11 |
---|---|
[Eclipse] Working Set 만들기 (0) | 2013.04.10 |
[Eclipse] svn ignore 하기 (0) | 2013.04.05 |
[Eclipse] Link With Editor (0) | 2013.04.03 |
[Eclipse] 인코딩 에러 Some characters cannot be mapped using "ISO-8859-1" character encoding. (0) | 2013.04.03 |
트랙백
댓글
글
java -classpath [jar파일] [실행할 클래스 파일명]
실행할 클래스 파일명은 풀 패키지 명을 입력해야 합니다.
예를 들어 jar 파일 구조가
com.test.Utils.class
com.test.MainWindow.class
로 구성된 jar 파일이
test.jar로 되어 있고 MainWindow.class 파일안에 main 메소드가 존재한다면
java -classpath test.jar com.test.MainWindow
로 실행하면 됩니다.
'Java > Java' 카테고리의 다른 글
[Java] JDBC SQL Server 연결 URL (0) | 2013.07.18 |
---|---|
[Java] 윈도우 JDK 버전 확인 (0) | 2013.05.10 |
[Java] JDK Download (0) | 2013.04.02 |
[Java] Creating Custom Annotations and Using Them (0) | 2013.01.21 |
[Java] Class<?> 의 의미? (0) | 2013.01.21 |
트랙백
댓글
글
링크 : http://blog.naver.com/artfile?Redirect=Log&logNo=130160553266
stucts에서 처음 타일즈를 써봤는데 공통 부분을 모듈화 해서 관리하는 점은 편했는데
관리파일이 하나의 xml이어서 공동작업시 불편했다.
스프링에서 제공하는 클래스를 이용하면 분산 설정이 가능하다.
'Java > SpringFramework' 카테고리의 다른 글
[Spring] Commons configuration을 사용한 스프링 운영 환경 설정값 지정 (0) | 2013.07.29 |
---|---|
[Spring] JSON 마샬링, 언마샬링 (0) | 2013.07.22 |
[Spring] 스프링 버전 확인하기 (0) | 2013.04.03 |
[Spring] Spring - Quartz를 사용하여 스케줄러 구현하기 (0) | 2012.11.29 |
[Spring] Spring MVC에서 한글 처리 (0) | 2012.07.20 |
트랙백
댓글
글
링크 : http://mytory.net/archives/1015
링크 : http://libmarco.tistory.com/47
링크 : http://yysvip.tistory.com/182
* 주의사항 : 서버에 올라간호 파일을 ignore하면 안된다. 우선 서버의 동기화에서 제외할 파일을 삭제한후 적용시키면 된다.
'IDE/Tool > Eclipse' 카테고리의 다른 글
[Eclipse] Working Set 만들기 (0) | 2013.04.10 |
---|---|
[Eclipse] java 프로젝트에서 jar 파일 포함시키기 (0) | 2013.04.07 |
[Eclipse] Link With Editor (0) | 2013.04.03 |
[Eclipse] 인코딩 에러 Some characters cannot be mapped using "ISO-8859-1" character encoding. (0) | 2013.04.03 |
[Eclipse] eclipse.ini 설정 (0) | 2013.04.02 |
트랙백
댓글
글
Server.xml을 수정
<Context docBase="TEST" path="/" reloadable="true" source="org.eclipse.jst.j2ee.server:TEST">
<Resource auth="Container"
driverClassName="oracle.jdbc.driver.OracleDriver"
name="test"
password="password"
type="javax.sql.DataSource"
url="jdbc:oracle:thin:@127.0.0.1:1523:TESTDB"
username="username"/>
</Context>
'WAS > Tomcat' 카테고리의 다른 글
[Tomcat] Tomcat 7.0 번역 문서 (0) | 2013.07.31 |
---|---|
[Tomcat] Tomcat 6.0 JNDI 설정 (0) | 2013.07.29 |
[Tomcat] Class Loader HOW-TO (0) | 2012.10.24 |
[Tomcat] 버전별 서블릿 스펙 (0) | 2012.10.20 |
[Tomcat] Tomcat 4.1 JNDI 설정 (0) | 2012.10.19 |
트랙백
댓글
글
'OS > Linux' 카테고리의 다른 글
[Linux] 고급 Bash 스크립팅 가이드 (0) | 2013.12.30 |
---|---|
[Linux] 리눅스 명령어 (0) | 2013.12.25 |
Shell Script (0) | 2013.12.15 |
tar 압축, 해제 (0) | 2008.02.20 |
트랙백
댓글
글
해당 파일을 선택하면 Navigator의 트리 위치가 알아서 펼쳐지는 유용한 기능
'IDE/Tool > Eclipse' 카테고리의 다른 글
[Eclipse] java 프로젝트에서 jar 파일 포함시키기 (0) | 2013.04.07 |
---|---|
[Eclipse] svn ignore 하기 (0) | 2013.04.05 |
[Eclipse] 인코딩 에러 Some characters cannot be mapped using "ISO-8859-1" character encoding. (0) | 2013.04.03 |
[Eclipse] eclipse.ini 설정 (0) | 2013.04.02 |
[Eclipse] Plug-In 개발 (0) | 2012.10.25 |
트랙백
댓글
글
// 스프링 버전 확인하기
org.springframework.core.SpringVersion.getVersion()
'Java > SpringFramework' 카테고리의 다른 글
[Spring] JSON 마샬링, 언마샬링 (0) | 2013.07.22 |
---|---|
[Spring] Spring Tiles (0) | 2013.04.05 |
[Spring] Spring - Quartz를 사용하여 스케줄러 구현하기 (0) | 2012.11.29 |
[Spring] Spring MVC에서 한글 처리 (0) | 2012.07.20 |
[Spring] Springframework 2.5 fileupload (0) | 2012.07.04 |
트랙백
댓글
글
[Eclipse] 인코딩 에러 Some characters cannot be mapped using "ISO-8859-1" character encoding.
설정
Window -> Preferences -> General -> Content Types -> Text -> JSP -> Default-Encoding -> [변경]
'IDE/Tool > Eclipse' 카테고리의 다른 글
[Eclipse] svn ignore 하기 (0) | 2013.04.05 |
---|---|
[Eclipse] Link With Editor (0) | 2013.04.03 |
[Eclipse] eclipse.ini 설정 (0) | 2013.04.02 |
[Eclipse] Plug-In 개발 (0) | 2012.10.25 |
[Eclipse] Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required library (0) | 2012.10.20 |
트랙백
댓글
글
링크 : http://wiki.eclipse.org/Eclipse.ini
참고 : http://wiki.kwonnam.pe.kr/eclipse/config
Eclipse startup is controlled by the options in $ECLIPSE_HOME/eclipse.ini
. If $ECLIPSE_HOME
is not defined, the default eclipse.ini
in your Eclipse installation directory (or in the case of Mac, the Eclipse.app/Contents/MacOS
directory) is used.
eclipse.ini
is a text file containing command-line options that are added to the command line used when Eclipse is started up. There are many options available, please see here.
Important:
- Each option and each argument to an option must be on its own line.
- All lines after
-vmargs
are passed as arguments to the JVM, so all arguments and options for eclipse must be specified before-vmargs
(just like when you use arguments on the command-line) - Any use of
-vmargs
on the command-line replaces all-vmargs
settings in the .ini file unless--launcher.appendVmargs
is specified either in the .ini file or on the command-line. (doc)
By default, eclipse.ini
looks something like this (the exact contents will vary based on operating system and which Eclipse package you have):
-startup ../../../plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar --launcher.library ../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.100.v20110502 -product org.eclipse.epp.package.jee.product --launcher.defaultAction openFile -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m --launcher.defaultAction openFile -vmargs -Dosgi.requiredJavaVersion=1.5 -XX:MaxPermSize=256m -Xms40m -Xmx512m
Among other things, this sets the heap space to 40MB initially and a maximum of 512MB, and also specifies a maximum PermGen size of 256MB. A max heap of 512MB might be OK for some users, but it's often necessary to bump that value up for large project sets or when some third-party plugins are installed.
Specifying the JVM
One of the most recommended options to use is to specify a specific JVM for Eclipse to run on. Doing this ensures that you are absolutely certain which JVM Eclipse will run in and insulates you from system changes that can alter the "default" JVM for your system. Many a user has been tripped up because they thought they knew what JVM would be used by default, but they thought wrong. eclipse.ini lets you be CERTAIN.
The following examples of eclipse.ini
demonstrate correct usage of the -vm option.
Note the format of the -vm option - it is important to be exact:
- The -vm option and its value (the path) must be on separate lines.
- The value must be the full absolute or relative path to the Java executable, not just to the Java home directory.
- The -vm option must occur before the -vmargs option, since everything after -vmargs is passed directly to the JVM.
Here is an example of what eclipse.ini
might look like on a Windows system after you've added the -vm
argument and increased the maximum heap space:
-startup plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502 -product org.eclipse.epp.package.java.product --launcher.defaultAction openFile --launcher.XXMaxPermSize 256M -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m --launcher.defaultAction openFile -vm C:\Java\JDK\1.6\bin\javaw.exe -vmargs -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx1024m
Remember that the exact values will differ slightly depending on operating system and Eclipse package.
-vm value: Windows Example
This is how the -vm
argument might look on Windows (your exact path to javaw.exe
could be different, of course):
-vm C:\Java\JDK\1.6\bin\javaw.exe
This might not work on all systems. If you encounter "Java was started but returned exit code=1" error while starting the eclipse, modify the -vm
argument to point to jvm.dll
(exact path could be different):
-vm C:\Development\Java\64bit\jdk1.7.0_09\jre\bin\server\jvm.dll
-vm value: Linux Example
This is how the -vm argument might look on Linux (your exact path to java
could be different, of course):
-vm /opt/sun-jdk-1.6.0.02/bin/java
-vm value: Mac OS X Example
On a Mac OS X system, you can find eclipse.ini
by right-clicking (or Ctrl+click) on the Eclipse executable in Finder, choose Show Package Contents, and then locate eclipse.ini
in the MacOS
folder under Contents
.
To specify Java 6 for OS X:
-vm /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java
For versions of Mac OS X 10.7+ the location has changed to
/Library/Java/JavaVirtualMachines/<''jdk_name_ver''>/Contents/Home/...
To be safer, determine the location for the JDK you intend to use via the utility /usr/libexec/java_home and put this value with .../bin/java appended into the Eclipse.ini file.
'IDE/Tool > Eclipse' 카테고리의 다른 글
[Eclipse] Link With Editor (0) | 2013.04.03 |
---|---|
[Eclipse] 인코딩 에러 Some characters cannot be mapped using "ISO-8859-1" character encoding. (0) | 2013.04.03 |
[Eclipse] Plug-In 개발 (0) | 2012.10.25 |
[Eclipse] Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required library (0) | 2012.10.20 |
[Eclipse] org.eclipse.wst.common.project.facet.core.xml 설정 (0) | 2012.10.20 |
트랙백
댓글
글
출처 : http://technet.tmax.co.kr/kr/edocs/jeus/50/server/server-0011.htm#1000
3.8 J2EE 스펙 구현
[표 1]은 Sun Microsystems에서 제정한 J2EE의 스펙 중에서 JEUS 5 를 구현한 목록이다.
표 1. JEUS 5 가 지원하는 J2EE 스펙
Specification/Technology | Version supported in JEUS 5 |
Java 2 Platform, Enterprise Edition Specification | 1.4 |
J2EE Connector Specification | 1.5 |
Enterprise JavaBeans Specification | 2.1 |
Java Server Pages Specification | 2.0 |
Java Servlet Specification | 2.4 |
Java Naming and Directory Interface Specification | 1.2.1 |
Java Message Service Specification | 1.1 |
JDBC Specification | 3.0 |
JavaMail API Specification | 1.2 |
Java Transaction API Specification | 1.0.1 |
Java Transaction Service Specification | 1.1 |
JMX Specification | 1.2 |
JNLP Specification | 1.0.1 |
JAAS | 1.0.1 |
SOAP | 1.1 |
WSDL | 1.1 |
JAX-RPC (Full) | 1.0 |
SAAJ (Full) | 1.1 |
J2EE Web Services | 1.1 |
JACC | 1.0 |
위 스펙에 대한 내용을http://java.sun.com/j2ee/docs.html에서 구할 수 있다.
중요: 사용하는 JEUS edition에 따라서 위 표에서 나열된 모든 기능이 구현되지 않을 수 있다. 자세한 것은 각 JEUS edition의 소개 문서를 참조한다.
'WAS > Jeus' 카테고리의 다른 글
[Jeus] encoding 설정 (0) | 2012.07.07 |
---|---|
[Jeus] Tmax jeus (0) | 2012.06.20 |
[Jeus] 환경셋팅 (0) | 2012.06.14 |
[Jeus 5.0] Eclipse 에서 Jeus 디버깅이 안될때... (0) | 2012.06.14 |
트랙백
댓글
글
링크 : http://www.oracle.com/technetwork/java/javase/downloads/index.html
이전버전 : http://www.oracle.com/technetwork/java/javase/archive-139210.html
'Java > Java' 카테고리의 다른 글
[Java] 윈도우 JDK 버전 확인 (0) | 2013.05.10 |
---|---|
[Java] jar 파일 실행 시키기 (0) | 2013.04.07 |
[Java] Creating Custom Annotations and Using Them (0) | 2013.01.21 |
[Java] Class<?> 의 의미? (0) | 2013.01.21 |
[Java] JConsole 연결 옵션 (0) | 2013.01.05 |
트랙백
댓글
글
( 출처: http://sapeyes.blog.me/70118257910 )
번역 해주셔서 정말 감사합니다.
Lars Vogel이 2009/09/13~2011/08/24 기간 동안에 작성하고 계속 수정해온 튜토리얼이다.
http://www.vogella.de/articles/Git/article.html 에 원본이 있다.
단순히 번역만 하도록 한다.
1. Git
1.1 Git이란 무엇인가?
Git은 분산형 버전 관리 시스템 (DVCS, Distributed Version Control System)이며 C언어로 구현되었다. 버전 관리시스템은 당신이 어떤 파일 집합에 대한 히스토리를 생성하고 관리할 수 있도록 도우며 특정 다른 상태(어느 시점)으로 복귀(Revert)할 수 있는 기능을 가지고 있다. 파일 집합은 주로 소스코드들이다. 분산 버전 관리 시스템에서 모든 사용자는 완벽한 복사본을 가지고 있으며 (소스코드에 대한 히스토리를 포함) 버전 관리 명령어들을 각 사용자의 로컬에서 실행할 수 있다. DVCS는 중앙 저장소 사용을 항상 요구하지 않는 장점을 갖는다.
만약 당신이 소스코드에 수정을 가한다면 그것에 대해 버전 관리 시스템에 마크(mark)하고 (즉 index/staging으로 add) 그러고 난 뒤 저장소로 추가(commit)한다. Git은 당신이 복귀할 수 있는 모든 버전들을 관리하고 있다. Git 은 커밋을 당신의 지역 저장소로 하도록 하며 당신의 Remote 저장소로 동기화 하도록 돕는다. Git은 저장소들을 복사 (clone) (소스코드의 완벽한 히스토리를 포함)하는 기능도 있다. 저장소 실제 주인은 push (remote 저장소로 변경사항 전송) 과 pull (remote 저장소로부터 변경사항 받기) 의 두 명령을 통해 변경사항들을 동기화 한다.
Git은 분기 (Branching)을 지원한다. 즉 당신의 소스코드에 대한 다른 버전들을 당신이 마음대로 생성하여 가질 수 있도록 하는 것이다. 만일 당신이 새로운 특정 부분에 대해 개발을 원한다면 먼저 소스코드에 대한 분기(branch)를 열고 변경사항들을 마크 (즉 소스코드를 개발 혹은 수정하여 staging index 에 기록) 할 수 있다. Git은 모든 버전들을 추적한다.
Git은 명령어 콘솔로도 사용될 수 있다. 본 튜토리얼에서는 콘솔 명령어 위주로 설명한다. GUI기반 툴이 필요하다면 EGit (http://www.vogella.de/articles/EGit/article.html) 을 사용해 보길 바란다.
1.2 중요 용어 정리
Repository - 저장소
저장소는 히스토리, 시간/태그(Tag)/분기(Branch)에 따른 다른 버전들을 가지고 있다. Git에서 저장소를 다른곳으로 복사하더라도 다시 완벽한 저장소가 된다. 저장소는 작업하고 있는 복사본으로 수정본들을 얼마든지 검색할 수 있도록 한다.
Branches - 분기 와 Tags - 태그
Git 저장서는 모든 분기들과 태그(tags)들을 가지고 있다. 분기들중 하나는 master라고 불리는 기본 분기이다. 사용자는 작업에 필요한 어떤 한 버전의 분기를 이 기본분기로 체크아웃(Checkout)한다. 이것을 작업 카피 (Working Copy)라고 한다.
Commit - 커밋
소스 수정사항들은 저장소로 커밋할 수 있다. 이것은 지난 시간까지 추적된 것에 대한 새로운 리비전(Revision)을 만드는 것이다. 각 커밋은 저자와 커밋한 내용(어떻게 수정을 했는지, 누가 커밋 했는지)을 저장한다.
URL
Git에서 URL은 저장소의 위치이다.
Revision - 리비전
소스코드의 버전을 가리킨다. Git은 SHA1 ids으로 리비전을 구분한다. SHA1 ids는 160비트 으로 긴 편이고 16진수로 표현된다. 가장 최신버전은 HEAD로 불리는 주소로 표현되며 이전 버전은 HEAD~1으로 계속 그런 방식으로 버전이름을 가리킬 수 있다.
1.3 Staging Index
(저자 왈 : Staging은 임시적인 공간, 혹은 단계를 가리킴)
Git 은 당신이 변경사항들을 명확하게 표기하길 요구하고 저장에 적절하게 수정사항들이 표기되길 원한다. 예를들어 당신이 새로운 파일을 다음 변경사항에 적용하고 싶으면 소위 'staging index'에 그 파일들을 'add file' 명령을 이용해 넣으면 된다. Staging index는 변경사항들에 대한 완벽한 스냅샷이다.
2. 설치
우분투에서는 "sudo apt-get install git-core"
윈도우에서는 http://code.google.com/p/msysgit/ 에서 참고
3. 셋업 (Setup)
Git은 ".gitconfig" 파일에 전역 환경설정내용을 저장하고 있다. 이 파일은 사용자의 홈 디렉토리에 있으며 사용자와 비밀번호 혹은 소스코드 글자색상등을 수정할 수 있다.
3.1 사용자 설정 (User Configuration)
사용자와 사용자 이메일을 Git을 위해 설정하는 것은 다음 명령어를 통해 진행될 수 있다.
# Git에서 사용될 사용자 설정하기
# 당신의 이름으로 설정하면 된다.
git config --global user.name "Lars Vogel"
# 이메일 주소도 당신의 것으로 설정하면 된다.
git config --global user.email "Lars.Vogel@gmail.com"
# Set default so that always all changes are pushed to the repository (이건 무슨말인지 잘 모르겠음)
git config --global push.default "matching"
그리고 Git 설정사항을 확인하기 위해서는
git config --list
3.2 컬러 하이라이트
콘솔모드에서 글자 하이라이트 설정하는 명령어
git config --global color.status auto
git config --global color.branch auto
3.3 특정 파일 (커밋) 무시하기
Git에게 ".gitignore"파일을 통해 무시하고 싶은 디렉토리를 알려줄 수 있다. 혹은 파일의 패턴을 알려줄 수 있다. 에를들어 git에게 "bin" 폴더를 무시하고 싶다고 알려주고 싶다면 ".gitignore"파일에 다음과 같이 쓰면 된다.
bin
4. Git 시작하기
다음 내용들은 Git 을 가지고 일을 하는 방법에 대한 가이드이다. 몇개의 파일들을 생성하게 될 것이고 지역 Git 저장소를 생성한 후 당신의 파일을 커밋하게 될 것이다. 이후에는 저장소를 클론한 뒤 push, pull 하여 저장소간 변경사항들을 동기화 하는 방법을 알아보게 될 것이다. 명령어 창을 열고 다음 명령들을 입력해보길 바란다. 명령어 윗줄에 적은 코멘트들은 명령어를 기입하는 이유로 적힌 내용들이다.
4.1 내용 생성하기 (Create Content)
버전 관리를 받고 싶은 컨텐츠를 생성한다.
# 홈 디렉토리로 이동하기 cd ~/ # 저장소 폴더 생성하기 mkdir ~/repo01.git # 저장소 폴더로 이동하기 cd repo01.git # 폴더 생성하기 mkdir datafiles # 파일 생성하기 touch test01 touch test02 touch test03 touch datafiles/data.txt # 첫번째 파일에 몇가지 텍스트 기입하기 ls >test01
4.2 저장소 생성하고 커밋하기
모든 Git 저장소는 .git 폴더에 저장되어 있으며 .git 폴더는 당신이 생성한 git 저장소 폴더안에 있다. .git 폴더는 저장소의 환결설정 정보와 저장소의 완벽한 히스토리 정보를 담고 있다. 다음은 Git 저장소를 생성하는 명령어와 파일들을 저장소의 인덱스어 추가하고 변경사항을 커밋하는 과정을 나타낸다.
# 지역 Git 저장소 초기화 하기 (즉 저장소 만들기) git init # 모든 파일을 저장소로 추가하기 git add . # 지역 저장소로 커밋하기 (첫번째 리비전 만들기) git commit -m "Initial commit" # 로그 파일 보기 git log
4.3 diff 명령으로 차이점 확인 뒤, 차이점 커밋하기
먼저 파일에 변경 가한 뒤, 차이가 생긴 부분들을 한눈에 보고, 이를 저장소로 커밋하기
# 파일 변경하기 echo "This is a change" > test01 echo "and this is another change" > test02 # 변경사항들을 diff명령으로 확인하기 git diff # 변경사항 커밋하기, -a는 수정된 파일들에 대해서만 커밋함 # 하지만 새로운 파일은 자동으로 추가하지 않음 git commit -a -m "These are new changes"
4.4 Status, Diff 와 커밋 Log
다음 명령들은 현재 상태(status)와 커밋 리스트를 보기 위한 것이다.
# 파일에 변경 가하기 echo "This is a new change" > test01 echo "and this is another new change" > test02 // 현재 저장소 상태 확인하기 (파일의 변경/생성/삭제을 나타냄) git status // 마지막에 커밋한 내용과의 차이점 확인하기 git diff // 커밋하기 (-a 명령은 수정된 파일이 커밋되도록 하는 것) // -a 명령 없이 커밋하려면 사전에 git add test01, git add test02 해야함 git commit -a -m "More changes - typo in the commit message" // 커밋 히스토리 확인하기 git log // 변경사항 GUI로 확인하기 gitk --all
4.5 커밋 메세지 수정하기 - git amend
위 예제에서 커밋 메세지가 틀렸었다. --amend 파라미터를 이용해 마지막 커밋 메세지를 바꿀 수 있다.
git commit --amend -m "More changes - now correct"
4.6 파일 삭제
만일 버전관리를 받던 파일을 삭제했을 경우 "git add ."명령은 staging index에서 파일 제거를 할 수 없다. -A 옵션을 사용하여 "git add -A ."을 할경우 파일 제거가 적용된다. 혹은 커밋 명령어에서 -a옵션을 주면 된다. "git commit -a -m ..." (-a옵션 권장)
# 파일을 생성하고 버전관리를 받도록 한다. touch nonsense.txt git add . && git commit -m "a new file has been created" # 파일을 제거한다. rm nonsense.txt # 일반적인 커밋을 시도해본다 -> 실패한다. git add . && git commit -m "a new file has been created" # -a 옵션을 사용하여 커밋을 해본다. git commit -a -m"File nosense.txt is now removed" # 또는 대신 staging index에서 제거된 파일을 적용하려면 git add -A . 을 이용하여도 된다. git add -A . git commit -m "File nosense.txt is now removed"
4.7 Remote (Bare) Git 저장소 설정하기
이제 Remote Git 저장소를 생성한다. Git 은 원격 저장소를 네트워크나 로컬이나 상관없이 저장하는 것을 가능하게 한다. 단순하게 설명하기 위해서 로컬 원격 git 저장소를 시도해본다. 일반적인 git 저장소는 원격 git 저장소와 다르다. 일반적인 git 저장소는 소스코드와 git 저장소를 가지고 있다. 이 폴더에서 바로 당신은 아무 작업이나 할 수 있으며, 저장소는 소스코드의 Working Copy를 가지고 있기 때문이다. 원격 저장소는 작업 복사본(Working copy)을 가지고 있지 않다. 저장소 파일만 가지고 있다. 이러한 저장소를 생성하기 위해선 "--bare" 플래그를 사용한다.
# 저장소로 이동 cd ~/repo01.git # git clone --bare . ../remote-repository.git # 복사된 파일들이 같은지 확인 (.git 폴더에 있는 파일) ls ~//remote-repository.git
4.8 다른 저장소로 변경내용 Push 하기
먼저 첫번째 저장소에서 파일에 변경을 가한 뒤에, 원격 저장소로 변경내용 Push 하기
# 첫번째 저장소로 이동해서 변경을 가해보자 cd ~/repo01 # 다음과 같이 두 파일의 내용을 변경한다. echo "Hello, hello. Turn your radio on" > test01 echo "Bye, bye. Turn your radio off" > test02 # 수정된 파일에 대해 커밋을 하려면 -a 옵션을 이용해 commit 을 실행한다. # 단, 새로 추가된 파일에 대해서는 자동으로 커밋해주진 않는다. git commit -a -m "Some changes" # 자, 원격 저장소로 푸쉬해보자. git push ../remote-repository.git
4.9 Add Remote
원격 저장소로 Push 하는 경우 URL을 전부 써야하는 불편이 있다. 이 주소를 줄여서 사용할 방법이 있으며 "git remote add 별명 url" 형식으로 줄인다. 별명 중에서 "origin"은 특별한 이름으로, 만일 저장소를 clone하여 사용할 경우 자동으로 해당 저장소를 origin으로 별명을 지정하여 사용되는 키워드이다. origin은 원번 저장소를 가리키는 말이고 작업을 최초로 시작하게 된 곳을 가리키게 된다. 다음과 같이 저장소를 최초로 생성해 사용하는 경우에는 origin이 없으며 한번 등록하게 되면 계속 사용 가능하다.
# ../remote-repository.git 저장소를 origin으로 추가한다. git remote add origin ../remote-repository.git # 자 현 저장소(working copy)에 수정을 가한다. echo "I added a remote repo" > test02 # Staging index 로 commit 한다. git commit -a -m "This is a test for the new remote origin" # origin으로 push 한다. 만일 git push 만 입력할 경우 자동으로 origin으로 보내게 된다. git push origin
4.10 저장소 clone하기
당신의 저장소를 새로운 폴더로 checkout 하는 방법.
(Checkout a new version of your repository into a new directory)
# 홈 폴더로 이동한 뒤에 cd ~ # 새로운 저장소 폴더를 만들자. mkdir repo02.git # 새로운 저장소 폴더로 이동한 뒤에 cd ~/repo02.git # 원격(origin) 저장소로 부터 체크아웃 받자. git clone ../remote-repository.git .
4.11 변경내용 Push 및 Pull 하기
Pull 은 최신 변경 내용을 다른 저장소로 보내는 작업이다. 새로운 저장소에서 변경된 파일들이 있을경우 push 명령을 통해 변경내용을 원격 저장소로 보낼수 있으며 pull 명령을 통해 이러한 변경사항들을 첫번째 저장소로 끌어올 수 있다.
두번째 저장소 (내용 변경됨, 최신버전) -> Push -> 원격 저장소 (최신버전)
첫번째 저장소 (구버전->최신버전) <- Pull <- 원격저장소 (최신버전)
# 홈 폴더로 이동 cd ~ # 두번째 저장소로 이동한다 cd ~/repo02.git # 변경을 가한다. echo "A change" > test01 # 커밋 git commit -a -m "A change" # 원격 저장소로 커밋한다. # origin은 clone 명령어를 사용했기 때문에 이미 등록되어 있다. git push origin # 첫번째 저장소로 이동한다. 그리고 변경내용을 pull 한다. cd ~/repo01.git git pull ../remote-repository.git/ # 최신 내용이 적용되었는지 파일 내용 확인 less test01
5. Revert Changes (변경사항 Revert-되돌리기)
만약 working copy에서 파일들을 새로 생성했는데 이 파일들을 커밋하고 싶지 않다면 다음과 같이 하면 된다. (아직 변경 내용을 staging 영역으로 올리지 않았을 경우입니다. - git clean )
# 파일 생성하기 touch test04 echo "this is trash" > test04 # dry-run 해보기 (즉 변경사항 취소하면 무슨 파일에 영향이 오는지 보기) # -n 옵션이 dry-run 입니다. git clean -n # 자 이제 지웁시다. git clean -f
예전에 커밋된 버전들중에서 구버전으로 체크아웃 할 수 있습니다.
git log 명령을 치면 commit 이름이 암호문처럼 길게 나온게 있는데 그 커밋 이름을 쓰면 됩니다.
(되돌아 갈때 Conflict 가 발생할 수도 있는데, 이런경우 파일에 /HEAD 부분(최신버전)과 구버전을 구분하여 파일을 남겨둔다. - 변역자 경험임, 경험이 부족해서인지 이부분 난해하게 느껴집니다.)
(참! 특정 버전으로 checkout 하게 되면 원래의 working copy는 HEAD 버전으로 그대로 남아있구요, 이름이 없는 Branch로 들어가서 구버전을 테스트할 수 있는 상태로 됩니다. git branch 해보면 되요. 여기서 수정,커밋도 됩니다. 본래로 돌아가려면 git checkout master라고 해도 되네요.)
# 첫번째 저장소로 가본다. cd ~/repo01.git # 커밋 로그를 확인하면, commit 다음에 영문숫자 암호코드가 있는데 이것이 커밋 이름입니다. 다른 이름도 있는데요, 최신버전은 HEAD, 그 바로 아래 버전은 HEAD~1 입니다. git log # 자 구버전 중에서 하나를 골라 체크아웃 하면, 구버전으로 돌아갑니다. git checkout commit_name
만약 Staging index로 변경내용을 적용하지 (add 하지) 않았다면 바로 변경내용을 버릴 수 있다.
# 몇가지 멍청한 실수를 저질렀다고 치자. echo "stupid change" > test01 # Staging Index으로 커밋하지 않았을 경우에는 checkout 받으면 이전 버전으로 돌아갈 수 있다. git checkout test01 # 잘 돌아갔는지 내용을 확인해 보자. cat test01 # 또 실수를 저질렀다고 치자. echo "another stupid change" > test01 # 이번엔 Staging Index로 변경내용을 적용했다. (add, commit 명령어는 staging 영역을 건드림) git add test01 # Staging Index의 test01을 원래대로 복원한다. git reset HEAD test01 # Staging Index로 부터 본래 파일을 Working Copy로 checkout함으로써 실수한 내용을 원래의 내용으로 최종 복원한다. (크아아악 복잡해) git checkout test01
Revert 명령으로 커밋을 되돌릴 수(Revert) 있다.
#Revert a commit git revert commit_name
(ex) git revert HEAD // 또 실행할 경우 바로 이전 commit과 최신 커밋을 계속 반복하며 복원함
- git reset --hard HEAD // 무조건 HEAD로 복원 (working copy, staging index 모두)
만약 파일을 Index에 추가하였는데 커밋을 하고 싶지 않다면 index에서 없앨 수 있다.
// 파일을 생성 touch incorrect.txt // 실수로 파일을 첨부함 git add . // 이 파일만 commit에서 제외하고 싶을 때 git reset incorrect.txt // 자 이제 편히 지우세요. rm incorrect.txt
6. Tagging in Git (태그 사용하기)
Git은 히스토리에 존재하는 특정 버전에 대해 태그를 사용할 수 있는 옵션이 있다. 따라서 좀더 편하게 원하는 예전 소스들을 참고할 수 있게된다. 대부분 일반적으로는 공개적으로 릴리스된 버전들에 대해 태그를 주로 달아 쓴다.
다음 명령을 통해 현재 사용중인 태그를 확인할 수 있다.
git tag
새로운 태그는 다음과 같이 생성한다.
git tag -a version1.6 -m 'version 1.6'
만약 태그와 관련된 소스를 사용하고 싶을 경우 다음과 같이 체크아웃 한다.
git checkout <tag_name>
7. 분기 및 합치기 (Branches and Merging)
7.1 분기 (Branches)
Git은 분기를 생성할 수 있다. 예를들면 소스코드의 독립적인 카피를 만드는 것이다. 각 분기 독립적으로 소스를 수정할 수 있다. 기본 분기는 master이다. git은 분기를 거의 시간을 들이지 않고 아주 빠르게 분기를 생성할 수 있다. 따라서 개발자들은 별 부담 느끼지 않고 마음대로 분기를 만들어 개발할 수 있게 된다.
다음 명령어는 현재 로컬 저장소의 분기 목록을 보여준다. 활성화된 분기는 * 마크가 붙어있다.
git branch
만약 모든 분기를 보고 싶다면 (원격 분기 포함) 다음 명령어를 사용한다.
git branch -a
새로운 분기는 다음과 같이 생성한다.
# Syntax: git branch <name> <hash> # hash 코드는 커밋 이름이다. 만일 과거 커밋중에서 테스트해보고 싶은 자료가 있다면 분기로 만들 수 있는데, 옵션이므로 꼭 사용할 필요는 없다. # Switch to your new branch git branch testing git checkout testing # 분기 testing에서 파일에 수정을 가해본 후 커밋을 한다. echo "Cool new feature in this branch" > test01 git commit -a -m "new feature" # 마스터 분기로 이동한다. git checkout master # 마스터 분기에서 수정사항이 적용되었는지 확인해본다. (안됨) cat test01
7.2 합치기 (Merging)
Merge는 두 분기의 차이를 결합하는 명령어이다. Merge는 3가지 방법으로 두 분기의 최신 커밋 HEAD를 결합한다. 결과적으로 새로운 HEAD를 갖게 된다. 특정 분기로부터 현재 활성화된 분기로 변경사항을 다음 명령을 통해 결합할 수 있다.
# Syntax: git merge <branch-name. git merge testing
만약 merge conflict 가 발생할 경우, git은 conflict 가 발생한 파일의 위치에 직접 표시를 해두어 프로그래머가 수동적으로 충돌난 소스를 수정할 수 있도록 돕는다. 수정이 끝난 후 프로그래머는 staging index로 파일을 추가하거나 commit할 수 있게 된다.
7.3 분기 삭제하기
더 이상 필요하지 않은 분기를 삭제하려면 다음 명령을 사용한다.
#Delete branch testing git branch -d testing # Check if branch has been deleted git branch
8. Merge Conflict 해결하기
Git은 merge conflicts 를 해결하는 방법을 제공한다. 다음 명령어들을 통해 일부러 conflict를 발생시켜보자.
# 첫번째 저장소로 이동 cd ~/repo01.git # 파일을 만들고 내용을 수정한다. touch mergeconflict.txt echo "Change in the first repo" > mergeconflict.txt # Stage로 추가한 뒤 commit한다. git add . && git commit -a -m "Will create merge conflict repo1" # 두번째 저장소로 이동한다. cd ~/repo02.git # 같은 파일을 만들고 내용을 수정한다. touch mergeconflict.txt echo "Change in the second repo" > mergeconflict.txt # Stage로 추가한뒤 commit한다. git add . && git commit -a -m "Will create merge conflict repo2" # master 저장소로 push한다. git push # 첫번째 저장소로 이동한다. cd ~/repo01.git # Push를 시도해본다. -> 거절 에러가 발생한다. git push # 변경사항을 master로 받는다. git pull origin master
위 마지막 명령어를 통해 최신 소스를 가져오면서 Git은 conflict가 발생한 파일의 소스 위치를 표시(mark)해 놓았다. 다음과 같다.
<<<<<<< HEAD Change in the first repo ======= Change in the second repo >>>>>>> b29196692f5ebfd10d8a9ca1911c8b08127c85f8
윗 부분은 현재 저장소에 있던 본래 소스이고, 아랫부분은 원격 저장소에 있던 자료이다. 자 이제부터 수동적으로 수정할 수 있고, 수정후에는 변경내용을 새롭게 커밋할 수 있게 된다. 또는 ' git mergetool '을 사용해도 된다. 이 툴은 두개의 vim 창으로 각 소스를 보여주어 좀 더 쉽게 충돌난 소스를 수정할 수 있도록 돕는다.
# 수동적으로 파일을 수정하거나 아니면 다음 결합툴을 사용할 수 있다. git mergetool # conflict 가 발생한 파일들을 순차적으로 보여주어, 새로운 파일에 어떤 내용을 넣을지 순차적으로 수정할 수 있게 한다. # 모든 내용을 수동적으로 수정한 뒤, 새로운 내용을 다시 커밋한다. git commit -m "merged changes"
9. Rebase
9.1 같은 분기에서 커밋들을 Rebase하기
Rebase는 다수의 커밋들을 하나의 커밋으로 만드는 명령어이다. 자, 필요없는 커밋들을 많이 해보자.
# 새로운 파일을 만든다. touch rebase.txt # Git에 추가한 뒤 커밋한다. git add . && git commit -m "rebase.txt added to index" # 별 필요없는 텍스트를 추가한 뒤 커밋하는 것을 반복한다. echo "content" >> rebase.txt git commit -am "added content" echo " more content" >> rebase.txt git commit -am "added more content" echo " more content" >> rebase.txt git commit -am "added more content" echo " more content" >> rebase.txt git commit -am "added more content" echo " more content" >> rebase.txt git commit -am "added more content" echo " more content" >> rebase.txt git commit -am "added more content" # 커밋된 내용을 확인 git log
자 이제 rebase.txt에 대한 커밋들을 합쳐보자.
git rebase -i HEAD~7
에디터는 커밋 메세지를 변경할 수 있게 한다.
(번역자:혹시 숫자를 너무 크게 쓰면 다른 소스랑 겹쳐서 에러가나는 바람에 rebase가 안될 수도 있다. 이때는 git rebase -abort 를 해주자. commit한 수를 세어서 숫자를 입력하길 바란다. 아니면 log에서 맨처음은 1로 보고 차근차근 세길 바란다. rebase후에는 git log를 해도 커밋 메세지는 그대로 남아있다. 아무래도 히스토리 내에서 결합이 이루어지는 것 같다.)
9.2 Rebase Branches
Git을 이용해 두개의 분기를 rebase할 수 있다. merge 명령이 두 분기를 합친것처럼 rebase는 한 분기의 변경사항을 이용하여 패치(patch)를 만들고 다른 분기에 이를 적용한다. 결과는 merge와 같지만 commit 히스토리가 좀더 깔끔하다. 즉 다른분기의 커밋 메세지가 master의 히스토리 최상단에 그대로 뜸으로써 연속성을 갖는다.
# 분기 생성 git branch testing # 새로운 분기로 이동 git checkout experiment # 소스 변경 echo "This will be rebased to master" > test01 # 변경내용 커밋 git commit -a -m "New feature in branch" # Master로 rebase하기 git rebase master
10. 패치 생성 및 적용하기
다음을 통해 분기를 생성한 뒤 수정된 내용의 패치를 만들고 master에 적용하는 법을 테스트 해보자.
# 새로운 분기 생성 git branch mybranch # 이동 git checkout mybranch # 변경 touch test05 # Change some content in an existing file echo "New content for test01" >test01 # 커밋 git add . git commit -a -m "First commit in the branch" # 패치 생성하기 --> git format-patch master (여러개가 생길 수 있다) git format-patch origin/master # 0001-First-commit-in-the-branch.patch 패치가 생성되었다. # master 분기로 이동한다. git checkout master # 패치를 적용한다. git apply 0001-First-commit-in-the-branch.patch # 패치를 지운다. rm 00* # master 분기에서 이제 일반적인 commit이 가능하다. git add . git commit -a -m "Applied patch"
* 역자 : git add .은 모든 파일이 staging index에 포함되기 때문에 조심해서 쓰는게 좋다. (git add 파일명 을 쓰거나 아니면 필요없는 파일은 지우거나 다른 곳으로 옮긴다.)
11. 별명 지정하기 (Alias)
특정 명령어에 대한 별명을 사용할 수 있다. 예를들어 git add-commit 명령어를 git add .-A 와 git commit -m 명령어로 결합하여 정의할 수 있다. 정의 후에는 "git add-commit "message"" 로 사용하면 된다.
git config --global alias.add-commit '!git add . -A && git commit -m'
12. 파일 또는 폴더 추적 멈추기 (Untrack)
간혹 저장소에 포함하지 말아야할 파일이나 폴더가 생길때가 있다. 만약 .gitignore 파일에 제외 파일/폴더 이름들을 기입하면 git은 기입 시점부터 track을 멈춘다. 이건 파일을 지우지는 않는다. 따라서 최신버전은 그대로 유지된다. Untrack 하려면 다음 명령어를 사용한다.
# .metadata 폴더를 untrack 하려는 경우 git rm -r --cached .metadata # test.txt 파일을 untrack 하려는 경우 git rm --cached test.txt
파일은 지워지지 않는다. 이전 커밋 히스토리 까지는 파일이 여전히 남아있다. 만일 히스토리상에서 사라지길 원한다면 "git filter-branch"를 살펴보길 바란다. 이 명령어는 커밋 히스토리를 수정하기 위해 사용되는 것이다.
13. 원격 저장소
13.1 원격 저장소 클론하기 (Clone)
Git은 원격 명령을 실행할 수 있다. 전송 프로토콜 타입을 지정할 수도 있다. Native(기본 제공 프로토콜)은 git protocol이다.
git clone git://dev.eclipse.org/org.eclipse.jface/org.eclipse.jface.snippets.git
대신 HTTP 프로토콜로 같은 저장소를 클론할 수도 있다.
git clone http://dev.eclipse.org/git/org.eclipse.jface/org.eclipse.jface.snippets.git
13.2 원격 저장소 추가하기
(이미 나온내용이지만 번역한다.) 원격 저장소를 커밋하면 기본 저장소는 자동으로 origin을 생성하여 push 명령을 통해 다시 수정내용을 적용할 수 있도록 해준다. 그리고 더 많은 원격 저장소를 "git remote add name 원격저장소주소"로 늘릴 수 있다. 예를들어 만약 위 git 프로토콜 주소로 클론을 했을 경우, 다음과 같이 http 주소를 추가할 수 있다.
// Add the http protocol git remote add githttp http://dev.eclipse.org/git/org.eclipse.jface/org.eclipse.jface.snippets.git
13.3 원격 명령어 (http / proxy)
http 프로토콜을 사용해 git 저장소를 복제하는것이 가능하다. 만약 방화벽이 http를 제외한 다른것을 모두 막는 경우, http를 이용한 복제가 매우 유용해진다. 예를들어 다음 명령어를 통해 이클립스 프로젝트를 http와 proxy를 통해 복제할 수 있다.
환경변수를 이용하는 방법
// Linux export http_proxy=http://proxy:8080 // On Windows // set http_proxy=http://proxy:8080 git clone http://dev.eclipse.org/git/org.eclipse.jface/org.eclipse.jface.snippets.git // push back to the origin using https git push origin
git config를 이용하는 방법
// Set proxy for git globally git config --global http.proxy http://proxy:8080 // To check the proxy settings git config --get http.proxy // Just in case you need to you can also revoke the proxy settings git config --global --unset http.proxy
14. 기타 유용한 명령어들
일상 작업에서 유용할만한 기타 명령어들이다.
git blame filename
- 누가 생성하고 수정했는지 나타냄
git checkout -b mybranch master~1
- 새로운 분기를 master와 똑같도록 생성하지만 마지막 커밋 바로 이전의 내용이다.
15. git 서버 설치하기
지금까지 설명한바에 의하면 서버는 굳이 필요 없다. 단순히 로컬 파일 시스템에서 사용하거나 공용 git privder (Github)를 사용하면 된다. 하지만 간혹 편리성을 위해 사설 서버가 필요할 수 있다. ubuntu에서 설치하는 방법을 설명한다. 매우 쉽다.
먼저 SSH가 설치되어 있는지 확실히 해둔다.
apt-get install ssh
Git을 설치한다. (설치 하지 않았을 경우)
sudo apt-get install git-core
Git 사용자로 로그인 한뒤 bare repository (원격 저장소 - working copy가 없음) 을 만든다.
# login to server # to test use localhost ssh git@IP_ADDRESS_OF_SERVER # Create repository mkdir example.git cd example.git git --bare init
이제부터 원격 저장소로 커밋할 수 있다.
mkdir gitexample cd gitexample git init touch README git add README git commit -m 'first commit' git remote add origin git@IP_ADDRESS_OF_SERVER:example.git git push origin master
16. GitHub
지금까지 해온 작업은 서버와 연관은 없었다. 서버를 사용하려면 프리 호스팅 서버를 이용할 수 있다.
GitHub는 ssh key를 필요로 한다. ssh키를 생성하려면 우분투에서 키생성하는 방법을 검색해 보길 바란다. (http://help.github.com/linux-set-up-git/) 윈도우에서는 msysgit 을 사용하면 된다. (http://help.github.com/msysgit-key-setup/)
GitHub에서 계정을 생성하고 저장소를 만들기 바란다. 저장소 생성뒤 GitHub에서 프로젝트를 업로드 하기 위한 명령어들을 알려준다. 이 명령어를 따라서 프로젝트를 업로드하길 바란다.
17. Git을 위한 GUI Tool
Git에는 자체 GUI 툴이 있다. 히스토리를 보여주는 gitk 와 git 명령어들을 사용할 수 있는 git gui이다.
윈도우에서는 TortoisGit(http://code.google.com/p/tortoisegit/) 이 있다. 이것은 TortoisSVN(http://tortoisesvn.tigris.org/ 과 비슷하다.
이클립스용 툴도 있다. (http://www.vogella.de/articles/EGit/article.html)
투토리얼 저자를 후원하시려면 (http://book.git-scm.com/3_git_tag.html, http://bit.ly/oiFUXT)
링크모음
Video with Linus Torwalds on Git
http://code.google.com/p/msysgit/ Git on Windows
http://github.com/guides/git-cheat-sheet Git Cheat Sheets
http://github.com/blog/626-announcing-svn-support SVN Support for GitHub
Git in 5 Minutes by Scott Paul Robertson
http://www.ibm.com/developerworks/opensource/library/l-git-subversion-1/index.html
- Translated by Chim (sapeyes) -
혹시 이해가 안되는 부분이 있을 경우 http://book.git-scm.com/index.html 사이트에서
관련 내용을 참고해보시길 바랍니다.
'VCS > Git' 카테고리의 다른 글
[Git] Advanced Git (0) | 2013.11.27 |
---|---|
[Git] Git은 어떻게 동작하는가? (0) | 2013.11.26 |
[Git] Tortoisegit (0) | 2013.04.15 |
[Git] SourceTree (windows) (0) | 2013.03.30 |
[Git] A successful git branching model (1) | 2012.11.14 |
트랙백
댓글
글
'VCS > Git' 카테고리의 다른 글
[Git] Advanced Git (0) | 2013.11.27 |
---|---|
[Git] Git은 어떻게 동작하는가? (0) | 2013.11.26 |
[Git] Tortoisegit (0) | 2013.04.15 |
[Git] Git Tutorial (0) | 2013.04.01 |
[Git] A successful git branching model (1) | 2012.11.14 |
트랙백
댓글
글
링크 : http://msdn.microsoft.com/en-us/library/ms997619.aspx
Design Specifications and Guidelines - Visual Design
Layout
Size, spacing, and placement of information are critical in creating a visually consistent and predictable environment. Visual structure is also important for communicating the purpose of the elements displayed in a window. In general, follow the layout conventions for how information is read. In Western countries, this means left-to-right, top-to-bottom, with the most important information located in the upper left corner.
The system defines the size and location of user interface elements in a window based on dialog units (DLUs), not pixels. A dialog unit is the device-independent measure to use for layout. One horizontal dialog unit is equal to one-fourth of the average character width for the current system font. One vertical dialog unit is equal to one-eighth of an average character height for the current system font. The default height for most single-line controls is 14 DLUs. Be careful if you use a pixel-based drawing program, because it may not provide an accurate representation when you translate your design into dialog units. If you do use a pixel-based drawing tool, you may want to take screen snapshots from a development tool that supports dialog units and use those images.
More Information
Your application can retrieve the number of pixels per base unit for the current display using the GetDialogBaseUnits function. For more information about this function, see the Microsoft Platform SDK on the MSDN Online Web site.
Size
The following table lists the typical height and width of common dialog box controls.
Size of Common Dialog Box Controls | ||
---|---|---|
Control | Height (DLUs) | Width (DLUs) |
Dialog boxes and property sheets | 263 max. (for 640 x 480 screen resolution) 218 215 188 | 263 max. (for 640 x 480 screen resolution) 252 227 212 |
(For property sheets, heights include 25 DLUs for property sheet button bars.) | ||
Command buttons | 14 | 50 |
Check boxes | 10 | As wide as needed |
Drop-down combo box and drop-down list | 10 | Size to match other drop-down combo boxes and text boxes |
Option buttons | 10 | As wide as needed |
Text boxes | 14 | Size to match other drop-down combo boxes and text boxes |
Text labels | 8 per line of text | As wide as needed |
Other screen text | 8 per line of text | As wide as needed |
More Information
To support localization, you should make controls wider than just enough to display the labels. For more information, see Chapter 15, "Special Design Considerations."
Toolbars and their buttons use pixels instead of dialog units for their measurement. The recommended sizes are shown in the following table.
Size of Toolbars and Toolbar Buttons | ||
---|---|---|
Control | Height (pixels) | Width (pixels) |
Toolbars in small button mode | 23 | Width of toolbar area or window |
Toolbars in large button mode | 28 | Width of toolbar area or window |
Small toolbar buttons | 21 | Depends on content; 22 if the button includes only an image |
Large toolbar buttons | 26 | Depends on content; 28 if the button includes only an image |
When you cannot reasonably apply the size guidelines for secondary windows, try to maintain a width within a task. This can provide a smooth transition, making it easier for a user to focus on the task. Also, always check to make sure that the window will fit in the minimum screen resolution set by your application's users. Typically, this means using a 640 x 480 resolution screen to ensure that it fits completely. You must also take into account the possible space taken up by the task bar and other desktop toolbars.
Make buttons a consistent length for readability. However, if maintaining this consistency greatly expands the space required for a set of buttons, it may be reasonable to have one button larger than the rest.
Similarly, if you use tabs, try to maintain a consistent width for all tabs in the same window (and in the same dimension). However, if a particular tab's label makes this unworkable, size it larger and maintain a smaller, consistent size for the other tabs. If a tab's label contains variable text, you can size the tab to fit the label, up to some reasonable maximum, after which you truncate the text and add an ellipsis.
Try to maintain a consistent width between text boxes and the list boxes they appear near, using only one or two different widths per group or window. If you localize your application, you should extend text, option button labels, and check box labels to be as wide as the group or window, where possible. This will reduce the work necessary to localize your interface.
Spacing and Positioning
Maintain a consistent margin from the edge of the window seven dialog units is recommended. Use spacing between groups within the window, as shown in Figure 14.27.
Figure 14.27 Recommended layout and spacing of controls and text (click to enlarge image)
The following table lists the typical items found in an interface and the recommended spacing between them.
Spacing Between Interface Items | ||
---|---|---|
Interface items | Use this spacing (DLUs) | |
Dialog box margins | 7 on all sides | |
Between paragraphs of text | 7 | |
Between text labels and their associated controls (for example, text boxes and list boxes) | 3 | |
Between related controls | 4 | |
Between unrelated controls | 7 | |
First control in a group box | 11 down from the top of the group box; align vertically to the group box title | |
Between controls in a group box | 4; align vertically to the group box title | |
Between horizontally or vertically arranged buttons | 4; align vertically to the group box title | |
From the left edge of a group box | 9; if the group box is left-aligned, controls are 16 from the left edge of the dialog box or property page | |
Last control in a group box | 7 above the bottom of the group box | |
Smallest space between controls | 2 | |
Text label beside a button | 3 down from the top of the button | |
Check box, list box, or option button beside a button | 2 down from the top of the button | |
Toolbars and their buttons use pixels instead of DLUs. The following table provides spacing for toolbar buttons.
Spacing for toolbar buttons | ||
---|---|---|
Button Size | Spacing | |
Small (16 x 16 pixel image) toolbar buttons | 3 pixels between a button and its text label 2 pixels above the toolbar image 3 pixels below the toolbar image | |
Large (20 x 20 pixel image) toolbar buttons | 3 pixels between a button and its text label 2 pixels above the toolbar image 2 pixels below the toolbar image | |
In general, for controls that do not contain their own labels, place the label to the left or above the related control. This makes it easier for users to associate the label with the corresponding control.
When a text box is the first item in the group box, use a smaller measurement so the visual spacing above and to the right looks equal. In cases where there are controls below a group box, align the controls to the edge of the group box above and use seven DLUs between the bottom edge of the group box and the control (or text), as shown in Figure 14.28.
Figure 14.28 Example of group box spacing (click to enlarge image)
Position controls in a toolbar so that there is at least a window's border width from the edges of the toolbar, as shown below.
Use at least 4 DLUs between controls, except for between a set of related toolbar buttons. There should be no space between adjacent toolbar buttons, such as a set of related option buttons.
For wizard design, Figure 14.29 shows suggested positioning and spacing.
Figure 14.29 Positioning and spacing in a wizard (click to enlarge image)
Grouping
Group related components you can use group box controls, separator lines, or spacing. Although you can also use color to visually group objects, it is not a common convention and could result in undesirable effects if the user changes color schemes.
A group box provides a strong visual element for related items. However, avoid using a group box when you have only one set of related items or where the group box may take too much space or add visual clutter rather than structure. Instead, consider using separators to group related items. Property sheets for files and folders are a good illustration of the use of separators rather than group boxes.
Stack the main command buttons in a secondary window in the upper right corner or in a row along the bottom, as shown in Figure 14.30. If there is a default button, it is typically the first button in the set. Place OK and Cancel buttons next to each other. If there is no OKbutton but there are command buttons that initiate action, place the Cancel button at the end of the buttons but before a Help button. If a particular command button applies only to a particular field, group it with that field.
More Information
For more information about button placement in secondary windows, see Chapter 9, "Secondary Windows."
Figure 14.30 Layout of buttons (click to enlarge image)
Group controls so that their location helps users understand the associated context or scope. For tabbed pages, follow these guidelines:
- When command buttons and other controls apply only to that page, place them within the border of the tabbed page.
- When command buttons and other controls apply to the entire window, place them outside the tabbed page.
Alignment
When information is positioned vertically, align fields by their left edges (in western countries). This usually makes it easier for the user to scan the information. Text labels are usually left-aligned and placed above or to the left of the areas to which they apply. When placing text labels to the left of text box controls, align the top of the text with text displayed in the text box.
In group boxes, controls should be left-aligned with the text label of the group. However, command buttons in the group should be right-aligned.
Align command buttons in most secondary windows at the top right or right-align them with the bottom. The exception is for message boxes, where command buttons should be centered. In toolbar arrangements, buttons and other controls are typically left- or top-aligned, depending on the layout of the area.
Required and Optional Input
For input form design, you may want to require certain input fields or controls and make others optional. To help users distinguish required input from optional input, provide some form of visual differentiation. The best way to do this is to separate the two sets of input into separate windows, panes, or groups and label the fields accordingly. However, this may not always work with the type of information you are presenting. The next best way is to label the individual fields with the words "required" or "optional" in parentheses. You can also use fonts, symbols, or graphics; however, such conventions require the user to learn the convention in order to use the application effectively. In scenarios where you cannot rely on training the user, use a more obvious form of identification. Do not use color unless you are using some other form of feedback as well. Color may attract the user's attention, but the perception of color can vary. Therefore, do not rely on it as the only means of identification.
Preview and Sample Boxes
In some situations, you may want to provide an area for a visual example of changes a user is making to an item, as shown in Figure 14.31.
Figure 14.31 Preview or sample box (click to enlarge image)
A sample is a representation of what might show up on screen, but it does not show the actual data that the user is working on. In contrast, a preview shows the user's actual data.
Include text, graphics, or both in your preview or sample boxes. The preview can be illustrative and interactive. If the preview is interactive, include instructions or some visual cue to let the user know that it is interactive.
Include a label for your preview or sample box, and keep the wording for the label brief. A one- or two-word label (often Preview or Sample) is usually sufficient unless the user needs to interact with the preview to update it. Use sentence-style capitalization for the label, but do not include ending punctuation unless the user can interact with the preview, in which case end the label with a colon.
Fundamentals of Designing User Interaction
Windows Interface Components
Design Specifications and Guidelines
Appendixes and References
'C/C++ > VC++ / MFC' 카테고리의 다른 글
[VC++] Visual Studio Predefine Macro (0) | 2013.05.01 |
---|---|
[VC++] Tray Icon Animation (0) | 2013.04.26 |
[VC++] 모듈 정의 파일(.def)을 이용해서 EXPORTS 시키기 (0) | 2013.03.08 |
[C++] C++11 (0) | 2013.01.29 |
[COM] WebBrowser Customization (0) | 2012.12.29 |
트랙백
댓글
글
OpenFileDialog open_file_dialog = new OpenFileDialog();
open_file_dialog.Filter = "dat Files|*.dat|All Files|*.*";
open_file_dialog.FilterIndex = 1;
open_file_dialog.RestoreDirectory = true;try
{
if (open_file_dialog.ShowDialog() == DialogResult.OK)
{
import_path = open_file_dialog.FileName;
}
}
catch (System.Exception)
{
}
'.Net > WinForm' 카테고리의 다른 글
[.Net] FolderbrowserDialog Custom Action (0) | 2014.02.08 |
---|---|
[WinForm] 서브클래스에서 OnPaint가 안될때... (0) | 2013.02.22 |
RECENT COMMENT