Environment Setup
Before beginning development with MyEclipse, ensure all necessary tools are installed. The primary requirement is the Java Development Kit (JDK). For web applications, Apache Tomcat is also needed.
Installing Required Components
Download and install JDK, Tomcat, and other related tools. Configuration of environment variables is essential for proper operation.
Configuring Java Environment
Set the JAVA_HOME system variable to point to your JDK installation directory, such as C:\Program Files\Java\jdk1.7.0. Update the PATH variable to include %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;.
After setting up, verify installation by running java -version in the command prompt.
Setting Up Tomcat
Create a CATALINA_HOME environment variable pointing to your Tomcat directory, e.g., E:\Program Files (x86)\apache-tomcat-7.0.81. Add %CATALINA_HOME%\lib;%CATALINA_HOME%\bin; to the PATH variable.
Start Tomcat using startup.bat located in the bin directory. Access http://localhost:8080 to confirm successful startup.
To change the default port, modify the port attribute in server.xml within the conf directory:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
Using MyEclipse
Upon launching MyEclipse, select an appropriate workspace location outside the C drive. Configure the encoding settings under Windows → Preferences → Workspace to UTF-8.
Adjusting Display Settings
Change the default font via Windows → Preferences → General → Appearance → Colors and Fonts → Basic. Select Text font and customize as desired.
Code Comment Templates
Configure comment templates for classes and methods:
For class comments:
/**
* Title: ${type_name}
* Description:
* Version:1.0.0
* @author ${user}
* @date ${date}
*/
For getters and setters, replace the relevant class file in the org.eclipse.jdt.ui jar with a updated version containing custom annotations.
Project Creation
Right-click in the Project Explorer or navigate to File → New → Other to create a new project. For Java web applications, choose Web Project.
Creating Classes
Within the project, create packages under src using the naming convention com.example.project. Then, create a new class and check "public static void main" to generate the entry point.
Use the template by typing /** followed by Enter to auto-generate documentation.
Running Applications
Execute programs through Run As → Java Application. Use Alt+/ for code completion features.
Debugging
Enable debugging by setting breakpoints in the code editor. Toggle breakpoints by double-clicking line numbers. During debug sessions, use F5 to step into methods, F6 to step over, and F8 to continue execution until the next breakpoint.
Managing Breakpoints
Disable all breakpoints temporarily using Run → Skip All Breakpoints or the corresponding toolbar icon.
Importing and Exporting Projects
Importing Projects
Use Import → General → Existing Projects into Workspace to bring existing projects into the workspace. For Maven projects, select Maven → Import Maven Projects.
Exporting Projects
Export projects using File → Export. Choose WAR or JAR formats for deployment.
Switching Workspaces
Access File → Switch Workspace to change between different workspaces. This action restarts MyEclipse.
Server Integration
Adding Tomcat Server
In MyEclipse: Windows → Preferences → MyEclipse → Servers → Tomcat. In Eclipse: Windows → Preferences → Servers → Runtime Environments. Add the server and configure it accordingly.
Deploy applications through the Servers view by right-clicking and selecting Add Deployment.
Essential Shortcuts
Common shortcuts include:
- Ctrl+H: Global search
- Ctrl+F: Find in current file
- Ctrl+Shift+R: Search files
- Ctrl+Shift+F: Format code
- Ctrl+Shift+O: Organize imports
- Ctrl+/ : Toggle comment
- Alt+/ : Content assist
- Ctrl+1: Quick fix
Additional useful shortcuts:
- Ctrl+D: Delete line
- Ctrl+Alt+↓/↑: Duplicate lines
- Ctrl+Shift+K: Find previous
- Ctrl+Shift+J: Reverse incremental search
- Ctrl+Shift+P: Match brackets
- Ctrl+Shift+T: Open type
- Ctrl+Shift+M: Add import
Plugin Management
Installing Plugins
Online installation: Help → Install New Software. Provide repository URLs for plugins like Alibaba's Java Coding Guidelines.
Offline installation: Copy plugin jars to the plugins folder and restart MyEclipse.
Viewing Source Code
Use jd-gui.exe to decompile .jar files. Alternatively, install Jadclipse plugin to view source directly in the IDE.
Advanced Features
Refactoring Tools
Use Alt+Shift+R for renaming, Alt+Shift+M for extracting methods, and Alt+Shift+L for local variable extraction.
Navigation
Navigate quickly using F3 to go to declarations, Ctrl+Shift+T to open types, and Ctrl+O to display outlines.
Code Assistance
Utilize Ctrl+Shift+F for formatting, Ctrl+Shift+O for organizing imports, and Ctrl+1 for quick fixes.