MyEclipse开发环境
- 格式:doc
- 大小:1.08 MB
- 文档页数:9
iAbout the T utorialEclipse is an integrated development environment (IDE) for Java and other programming languages like C, C++, PHP, and Ruby etc. Development environment provided by Eclipse includes the Eclipse Java development tools (JDT) for Java, Eclipse CDT for C/C++, and Eclipse PDT for PHP, among others.This tutorial will teach you how to use Eclipse in your day-2-day life while developing any software project using Eclipse IDE. We will give special emphasis on Java project. AudienceThis tutorial has been prepared for beginners to help them understand basic functionality of Eclipse tool. After completing this tutorial, you will find yourself at a moderate level of expertise in using Eclipse IDE from where you can take yourself to next levels. PrerequisitesWe assume you are going to use Eclipse IDE to handle all levels of Java projects development. So it will be good if you have knowledge of software development using any programming language specially Java programming.Copyright & Disclaimer© Copyright 2015 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book can retain a copy for future reference but commercial use of this data is not allowed. Distribution or republishing any content or a part of the content of this e-book in any manner is also not allowed without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or inthistutorial,******************************************iT able of ContentsAbout the Tutorial (i)Audience (i)Prerequisites (i)Copyright & Disclaimer (i)Table of Contents .................................................................................................................................... i i 1.OVERVIEW (1)What is Eclipse? (1)Licensing (1)Eclipse Releases (1)2.INSTALLATION (3)Downloading Eclipse (3)Installing Eclipse (3)Launching Eclipse (4)3.EXPLORE WINDOWS (5)Parts of an Eclipse Window (5)Using Multiple Windows (6)4.EXPLORE MENUS (7)Typical Eclipse Menus (7)Brief Description of Menus (8)Customizing Menus (8)5.EXPLORE VIEWS (9)About Views (9)Organizing Views (9)Moving Views (9)Creating View Folders (10)Opening a view (10)6.PERSPECTIVES (13)What is a Perspective? (13)Opening a Perspective (13)Switching between Perspectives (13)Closing a Perspective (14)Customizing a Perspective (14)7.WORKSPACES (16)About Eclipse Workspace (16)UI Elements for Managing the Workspace (16)8.CREATE JAVA PROJECT (18)Opening the New Java Project wizard (18)Using the New Java Project wizard (18)Viewing the Newly Created Project (20)9.CREATE JAVA PACKAGE (21)Opening the New Java Package wizard (21)Using the New Java Package Wizard (21)Viewing the Newly Created Package (22)10.CREATE JAVA CLASS (23)Opening the New Java Class Wizard (23)Using the New Java Class Wizard (23)Viewing the Newly Created Java class (24)11.CREATE JAVA INTERFACE (25)Opening the New Java Interface Wizard (25)Using the New Java Interface Wizard (25)Viewing the Newly Created Java Interface (26)12.CREATE XML FILE (27)Opening the New XML File wizard (27)Using the New XML File wizard (28)Viewing the Newly Created XML File (29)13.JAVA BUILD PATH (30)Setting the Java Build Path (30)14.RUN CONFIGURATION (31)Creating and Using a Run Configuration (31)15.RUNNING A PROGRAM (33)Running a Java Program (33)16.CREATE JAR FILES (35)Opening the Jar File wizard (35)Using the Jar File wizard (35)17.CLOSE PROJECT (37)Why Close a Project? (37)How to Close a Project? (37)Closed Project in Package Explorer (38)18.REOPEN PROJECT (39)Reopening a Closed Project (39)19.BUILD PROJECT (40)Building a Java Project (40)20.DEBUG CONFIGURATION (42)Creating and Using a Debug Configuration (42)21.DEBUGGING A PROGRAM (44)Debugging a Java Program (44)22.PREFERENCES (48)Setting Preferences (48)23.CONTENT ASSIST (50)Using Content Assist (50)24.QUICK FIX (52)Using Quix Fix (52)25.HOVER HELP (54)Using Hover Help (54)26.SEARCH MENU (56)Searching the Workspace (56)27.NAVIGATION (58)Navigating the Eclipse Workspace (58)Open Type (58)Open Type in Hierarchy (60)Open Resource (61)28.REFACTORING (63)Refactoring using Eclipse (63)29.ADD BOOKMARKS (64)About Bookmarks (64)Adding a Bookmark (64)Opening the Bookmarks View (64)Using the Bookmarks View (65)30.TASK MANAGEMENT (66)Managing Tasks (66)Opening the Tasks View (67)Using the Tasks View (67)31.INSTALL PLUGINS (69)Locating and Installing Plug-ins (69)32.CODE TEMPLATES (73)Using Code Templates (73)Modifying/Adding code templates (74)33.SHORTCUTS (75)About Shortcuts (75)34.RESTART OPTION (78)Restarting Eclipse (78)35.TIPS & TRICKS (79)36.WEB BROWSERS (81)Internal Web Browser (81)Eclipse 7What is Eclipse?In the context of computing, Eclipse is an integrated development environment (IDE) for developing applications using the Java programming language and other programming languages such as C/C++, Python, PERL, Ruby etc.The Eclipse platform which provides the foundation for the Eclipse IDE is composed of plug-ins and is designed to be extensible using additional plug-ins. Developed using Java, the Eclipse platform can be used to develop rich client applications, integrated development environments, and other tools. Eclipse can be used as an IDE for any programming language for which a plug-in is available.The Java Development Tools (JDT) project provides a plug-in that allows Eclipse to be used as a Java IDE, PyDev is a plugin that allows Eclipse to be used as a Python IDE, C/C++ Development Tools (CDT) is a plug-in that allows Eclipse to be used for developing application using C/C++, the Eclipse Scala plug-in allows Eclipse to be used an IDE to develop Scala applications and PHPeclipse is a plug-in to eclipse that provides complete development tool for PHP.LicensingEclipse platform and other plug-ins from the Eclipse foundation is released under the Eclipse Public License (EPL). EPL ensures that Eclipse is free to download and install. It also allows Eclipse to be modified and distributed.Eclipse ReleasesEvery year, since 2006, the Eclipse foundation releases the Eclipse Platform and a number of other plug-ins in June.1.Eclipse8Eclipse 9Downloading EclipseYou can download eclipse from /downloads/. The download page lists a number of flavors of eclipse.The capabilities of each packaging of eclipse are different. Java developers typically use Eclipse Classic or Eclipse IDE for developing Java applications.The drop down box in the right corner of the download page allows you to set the operating system on which eclipse is to be installed. You can choose between Windows, Linux and Mac. Eclipse is packaged as a zip file.Installing EclipseTo install on windows, you need a tool that can extract the contents of a zip file. For example you can use:∙7-zip ∙PeaZip ∙ IZArcUsing any one of these tools, extract the contents of the eclipse zip file to any folder of your choice.2.Launching EclipseOn the windows platform, if you extracted the contents of the zip file to c:\, then you can start eclipse by using c:\eclipse\eclipse.exeWhen eclipse starts up for the first time it prompts you for the location of the workspace folder. All your data will be stored in the workspace folder. You can accept the default or choose a new location.1011If you select "Use this as the default and do not ask again", this dialog box will not come up again. You can change this preference using the Workspaces Preference Page. See the Preference tutorialpage for more details.Eclipse 12Parts of an Eclipse WindowThe major visible parts of an eclipse window are:∙Views ∙Editors (all appear in one editor area) ∙Menu Bar ∙ ToolbarAn eclipse perspective is the name given to an initial collection and arrangement of views and an editor area. The default perspective is called java. An eclipse window can have multiple perspectives open in it but only one perspective can be active at any point of time. A user can switch between open perspectives or open a new perspective. A perspective controls what appears in some menus and tool bars.3.EclipseA perspective has only one editor area in which multiple editors can be open. The editor area is usually surrounded by multiple views. In general, editors are used to edit the project data and views are used to view the project metadata. For example, the package explorer shows the java files in the project and the java editor is used to edit a java file.The eclipse window can contain multiple editors and views but only one of them is active at any given point of time. The title bar of the active editor or view looks different from all the others.The UI elements on the menu bar and tool bar represent commands that can be triggered by an end user.Using Multiple WindowsMultiple Eclipse Windows can be open at the same time. To open a new window, click on the Windows menu and select the New Window menu item.Each window can have a different perspective open in them. For example you could open two Eclipse windows one in the Java perspective and the other in the Debug perspective. The window showing the Java perspective can be used for editing the java code and the window showing the debug perspective can be used for debugging the application being developed.13Eclipse 14T ypical Eclipse MenusThe typical menus available on the menu bar of an Eclipse window are:∙File menu ∙Edit menu ∙Navigate menu ∙Search menu ∙Project menu ∙Run menu ∙Window menu ∙ Help menu4.Plug-ins can add new menus and menu items. For example when the java editor is open, you will see the Source menu and when the XML editor is open, you will see the Design menu. Brief Description of Menus15Customizing MenusThe visible menu items on a menu depend on the installed plug-ins and customization done using the Customize Perspective dialog box.16Eclipse 17About ViewsEclipse views allow users to see a graphical representation of project metadata. For example the project navigator view presents a graphical representation of the folders and files associated with a project and properties view presents a graphical representation of an element selected in another view or editor.An eclipse perspective can show any number of views and editors. All editor instances appear in a single editor area, whereas views are placed inside view folders. A workbench window can display any number of view folders. Each view folder can display one or more views. Organizing ViewsThe following picture shows four views arranged in a view folder.The picture given below shows the same four views arranged in two view folders.5.Moving ViewsTo move a view from one view folder to another, just click on the view title and drag to the title bar area of another view folder. The green line shown below is a result of dragging the title bar of the Properties view from one view folder to the title bar area of another view folder. The Properties view can be moved to where the green line is by releasing the mouse button and sending out a drop event.Creating View FoldersView folders can be dynamically created by dragging the title bar of a view to anywhere outside the editor area and title bar of another view folder. As you drag the title bar around, green lines will indicate where exactly the new view folder will be created.Moving the drag icon to the bottom of a window allows you to create a view folder that spans the entire width of the window. Moving the drag icon to the left or right edge of window allows you to create a view folder that spans the entire height of the window.18Opening a viewTo open a view, click on the Window menu and select the Show View menu item.19Clicking on the Other menu item brings up the Show View dialog box that allows you to locate and activate a view.20The views are organized by category. To quickly locate a view, just type the name of a view into the filter text box. To open a view, select it and click on the OK button. The subsequent pages of this tutorial introduce you to a number of useful views.21End of ebook previewIf you liked what you saw…Buy it from our store @ https://22。
Myeclipse8.6搭建jbpm4.4的开发环境jbpm版本:4.4IDE:myeclipse8.6DB:mysql-5.0.261、Myeclipse中安装jbpm1)、解压jbpm4.42)、打开myeclipse8.6---->选择Help菜单---->选择Myeclipse Configuration Center------>打开第三个选项卡SoftWare----->选择右上角add site---->选折add form archive file-----》找到${jbpm_home}\install\src\gpd 目录下找到jbpm-gpd-site.zip即可!name随便输入即可(比如我输入jbpm)!这样下面就看到多一个jbpm(部分过程看下图)选择“add site”,弹出如下对话框:选择“Add from Archive File”,弹出如下对话框:选择“打开”,弹出如下对话框:选择“OK”,出现如下对话框:3)、一个一个选中jpd下面的文件,点击右击“add to profile”即可!4)、点击右下角“apply change”按钮即可!安装完成后会重启Myeclipse,重启后在新建项目里会多出一项“JBoss jBPM”,如下图所示:2、生成jbpm数据库表(这里以安装mysql为列)a)、先打开mysql数据库新建一个数据库比如jbpm(create database jbpm);b)、打开${jbpm_home}\install\src\db\create 下面,找到mysql的表脚本!c)、全部复制过来粘贴到mysql命令行上(当然也可以source ***.sql方式),3、搭建JBPM4运行环境一、下载JBPM4.3可以到官方下载,然后直接解压就可以了doc: 用户手册,javadoc和开发指南examples: 用户手册中用到的示例流程install: 安装脚本lib: 第三方库和一些特定的jBPM依赖库src: 源代码jbpm.jar: jBPM主库归档二、搭建JBPM4运行环境1、新建一个Java Project项目2、添加依赖库jar包a)jbpm.jar包b)JBPM目录/lib下的所有的jar包,当然了,这里有些是可选的。
前言:这个例子的view层用到了struts,DAO层用到了hibernate,由于逻辑及其简单(只是往数据库添加一条记录),所以暂时没有用到spring。
一、使用eclipse+struts+spring+hibernate+myeclipse+mysql开发配置过程。
1.jdk的安装:安装文件:jdk-1_5_0_15-windows-i586-p.exe说明:最好用jdk1.5,可以去sun主页下载,我这里已经下了,可以提供。
注意:最好在新装系统下安装,并且此前没有装过java相关的软件,以免出现版本或者path问题。
过程:可以直接安装到c盘根目录下即可,注意要记住安装路径,以后可能会用到。
2.web应用服务器tomcat的安装:安装文件:apache-tomcat-5.5.26.exe说明:要想构建jsp应用,web应用服务器是必须要有的,asp服务器为IIS,php服务器为Apache,jsp服务器比较多有weblogic和websphere(两者是商业级的,比较强大,但要收费),tomcat和resin(免费的,比较适用中小级应用,如果是大型应用则须考虑集群)。
在这里,我选用tomcat,因为它使用较广泛,网上相关的资料也比较多。
我并没有选择最新版本,原因是次新版本往往比最新版本更加稳定。
注意:必须先装jdk,否则不能安装tomcat(原因之一是tomcat在对jsp进行编译时用到了jdk,并且jdk是tomcat正常工作的前提)。
过程:可以直接安装到c盘默认路径,选择前面安装的jdk路径,并且修改端口8080为80(tomcat默认端口为8080,而一般我们通过IE访问时端口为80,需要注意的是要保证没有其他程序已经占用80端口(比如你已经装了iis或者apache),否则tomcat不能正常启动),控制台页面的管理员admin帐号暂时不设置密码。
测试页面http://127.0.0.1,检测是否安装成功,如果进入欢迎页面就表示tomcat安装成功。
MyEclipse 开发工具MyEclipse 企业级工作平台(MyEclipse Enterprise Workbench ,简称MyEclipse)是对Eclipse IDE 的扩展,利用它可以在数据库和Java EE 的开发、发布,以及应用程序服务器的整合方面极大的提高工作效率。
1.MyEclipse 工具窗口MyEclipse 是功能丰富的Java EE 集成开发环境,包括了完备的编码、调试、测试和发布功能,完整支持HTML5、Struts2、JSF 、CSS 、JavaScript 、SQL 、Hibernate 、XML 等。
简单而言,MyEclipse 是Eclipse 的插件,也是一款功能强大的Java EE 集成开发环境,如图1-23所示。
图1-23 MyEclipse 窗口在MyEclipse 6.0版本以前,都需要用户先安装Eclipse 工具,而MyEclipse 6.0版本以后可以直接安装。
本书以最新的MyEclipse 9.0版本,来介绍JSP 项目的开发,用户可以从官方网站下相关工具软件,并安装该软件。
2.MyEclipse 包含插件MyEclipse 与Eclipse 相比,功能比较强大。
MyEclipse 不仅在开发过程中,操作比较灵活,而包含了许单独的类(或插件)。
MyEclipse 所包含的功能及插件介绍如下:菜单栏 工具栏 透视图工具栏包资源管理器视图和层次结构视图 属性视图编辑器视图大纲视图Image(图片)和Snippets(片段)视图控制台、Server 、Web Browser 等视图●Java EE模型Java EE(Java Platform,Enterprise Edition)是Sun公司推出的企业级应用程序版本。
能够帮助开发人员开发和部署可移植、健壮、可伸缩且安全的服务器端Java应用程序。
Java EE是在Java SE 的基础上构建的,它提供Web服务、组件模型、管理和通信API,可以用来实现企业级的面向服务体系结构和Web 2.0应用程序。
Eclipse开发环境配置 最近要在2个多年前的⽼项⽬⾥添加功能,⽤idea启动失败之后,尝试使⽤Eclipse启动成功了。
⽼项⽬到什么程度呢? ⼀个是Maven项⽬,SpringMVC,要在Tomcat8上运⾏,数据源是在Tomcat的context.xml⽂件⾥的。
另⼀个是传统JavaWeb项⽬,jdk1.6,框架是:Spring + Struts + itatis,引⼊lib的jar,在Tomcat上运⾏,数据源也是在Tomcat6的context.xml⽂件⾥的。
所以本⼈只能重新捡起来多年未⽤的Eclipse,配置了1天时间,把配置过程,和启动项⽬过程总结⼀下。
1. Eclipse配置1.1 基础配置 Eclipse修改字体:Window --> Preferences --> General --> Appearance --> Colors and Fonts 修改通⽤字体:Basic --> Text Font 修改Java⽂件字体:Java --> Java Editor Text Font Eclipse修改项⽬字符集:右击项⽬ --> Properties --> Resource1.2 开发环境配置 配置过程默认JDK、Maven等环境变量都是配置好的。
开发模式:新装的Eclipse,默认是JavaEE模式,需要我们点击右上⾓的“Open Perspective”图标,选择Java,时候要使⽤Java模式开发。
Eclipse配置JDK:Window -> Preferences -> java -> install jres -> add -> standard vm -> 设置好相应的jre home(虽然名字叫jre home,建议选择jdk路径) Eclipse配置Maven:Window --> Preferences --> Maven --> Installations --> 设置maven Eclipse配置Tomcat:Window --> Preferences --> Servers --> 选择Tomcat对应的版本,添加Tomcat地址。
搭建Eclipse+MyEclipse+tomcat开发环境开发J2EE的第一步一、安装JDK首先下载JDK 5.0(JDK 5.0的下载页面为:/j2se/1.5.0/download.jsp);然后运行JDK 5.0安装程序jdk-1_5_0_06-windows-i586-p.exe,安装过程中所有选项保持默认;最后配置JDK的环境变量:在“我的电脑”上点右键—>“属性”—>“高级”—> “环境变量(N)”。
新建系统变量JAVA_HOME:C:\Program Files\Java\jdk1.5.0_06;新建系统变量CLASSPATH:.;%JAVA_HOME%\lib;(注意:点号表示当前目录,不能省略)在系统变量Path的值的前面加入以下内容:%JAVA_HOME%\bin;(注意:这里的分号不能省略) 到这里,JDK安装完毕。
下面我们测试一下JDK是否安装成功:将以下内容复制到记事本中:public class HelloJAVA{public static void main(String srg[]){System.out.println("Hello JAVA!");}}另存为“HelloJAVA.java”(不含引号,下同),并保存到D盘根目录下。
在命令行依次输入下图中红线所标注的命令:如果出现上图红框中所标注的内容,则说明JDK安装成功!注意:如果以后要安装诸如Eclipse、Borland JBuilder、JCreator、IntelliJ IDEA等集成开发环境(IDE,Integrated Developm ent Environment),应该在IDE中编译运行一个简单的HelloWorld程序,以保证IDE可以识别出JDK的位置。
二、安装Tomcat首先下载jakarta-tomcat-5.0.30.zip,之所以下载免安装版的好处是可以使用多个Tomcat (jakarta-tomcat-5.0.30.zip的下载页面为:/tomcat/tomcat-5/v5.0.30/bin/);然后将jakarta-tomcat-5.0.30.zip直接解压到D盘根目录:最后配置Tomcat的环境变量:在“我的电脑”上点右键—>“属性”—>“高级”—> “环境变量(N)”。
Windows下搭建Android开发平台(Myeclipse+SDK+ADT)(图文并茂)Myeclipse6.52.1版本下载地址:https:///android/repository/android-2.1_r01-windows.zip2.2版本下载地址:https:///android/repository/android-2.2_r01-windows.zip这里有一两个问题,请大家注意一下。
1)我刚开始目的是需要在Myeclipse中搭建Android2.1版本开发环境,我用的是Myeclipse6.5版本,如果本机安装Eclipse,也是同样可以安装Android开发环境的,都是像Myeclipse插件一样安装。
2)如果朋友你下载了SDK1.5以上的版本,可能会在Myeclipse里配置SDK路径是出问题,会报找到tools/adb.exe,当时我纳闷了一会,估计是版本问题,我就下载SDK1.5版本,发现tools下是有adb.exe(关于adb工具我会在另一篇文章说明),查了一些文章,也发现是版本高的原因,最后我还是先下载了1.5版本,然后进行更新操作安装,最后成功了。
3.安装ADT(Android Development Tools)进入MyEclipse,选择Help->Software Updates->Find and Install->Search for new features to install->New Remote Site. Name中填入:Android(名称随便写)https:///android/eclipse/。
点击OK就会自动安装。
4.在Myeclipse中配置SDK路径选择Windows->Preferences->Android(就是上面写的名称),选择Android SDK 的位置(到根目录级就好),比如C:/Java/android_sdk_1.5_r3。
OpenCV与MyEclipse 集成开发环境搭建一、下载OpenCV库官网下载OpenCV Win pack,下载地址:https:///opencv-3-4-1.html,下载得到的文件为opencv-3.4.1-vc14_vc15.exe,解压到指定目录OpenCV。
二、OpenCV与MyEclipse的集成2.1 OpenCV集成到JA V A项目(1)启动Myeclipse,新建JA V A项目,在JA V A项目中新建一个目录lib,用于存储第三方包。
(2)集成OpenCV到JA V A项目,从解压目录进入build\java目录,如下图所示:将opencv-341.jar文件拷贝到JA V A项目新建的目录中(lib)(3)将x64或x86目录中的文件opencv_java341.dll复制到项目使用的JDK\bin目录中。
(4)在opencv-341.jar上右击,弹出菜单,选择Build path->Add to Build path,如下图所示(5)测试是否运行正常在项目中新建一个运行类,在main方法中运行代码:System.loadLibrary(Core.NATIVE_LIBRARY_NAME);Mat m = Mat.eye(3, 3, CvType.CV_8UC1);System.out.println("m = " + m.dump());显示下列结果:2.2 OpenCV集成到MyEclipse(1)启动Myeclipse,单击工具栏上边的Window -> Preferences;(2)在弹出的窗口左侧单击Java -> Build path -> User libraries,单击new按钮,在弹出的New User Library中输入已经安装好的OpenCV库(OpenCV-3.4.1),如下图所示。
(3)在右边的按钮中点击Add External JARs, 选择到所安装的OpenCV路径下的build/java/ opencv-341.jar文件,如下图所示。
Eclipse搭建C语言开发环境Eclipse进行C/C++开发—Eclipse+CDT+MinGW的配置与使用详解1.简介Eclipse作为目前如日中天的开放式IDE,由于有大量插件支持,所以几乎无所不能,除了Java开发的老本行之外,C/C++开发也不在话下。
下面就给大家介绍如何使用CDT(C/C++ Development Tools)进行C/C++开发。
本文适合有一定Eclipse使用经验的读者,如果您对Eclipse的基本操作还很陌生,请先在网上搜索相关教程进行学习。
2.相关软件的下载准备2.1 下载Eclipse SDK +CDT安装和配置请先从下载的Eclipse SDK,目前的最新版本是3.3.1,然后从下载与Eclipse版本相配套的CDT2.2 下载Eclipse IDE for C/C++直接下载打包好的,这个版本包含了最新版本的eclipse IDE的核心和与之配套的CDT,免去了安装CDT的麻烦。
2.3下载安装JDK为了能够正常运行Eclipse,请确保你的计算机上装有JDK,并且已经配置好了环境变量。
2.4下载C/C++编译器由于CDT中并不自带编译器,所以还需要安装一个C/C++的编译器,这里给大家推荐的是MinGW,下载地址为,以下将使用MinGW-3.1.0-1进行讲解。
3.软件的安装3.1Eclipse SDK +CDT的安装以上软件凑齐之后,便可以进行安装配置了。
首先,解压Eclipse SDK的安装程序即可完成Eclipse的安装,这里假设将其解压到C:\路径下,则C:\下会出现一个名为“eclipse”的文件夹。
接着,将CDT的安装文件同样解压到C:\路径下,由于其解压后同样是名为“eclipse”的文件夹,所以会插入或覆盖相应的文件,解压完成后,CDT的安装工作便完成了。
3.2 Eclipse IDE for C/C++的安装这是一个压缩包,直接解压就可以,这里面包含了CDT.3.3C/C++编译器MinGW的安装安装MinGW,假设安装到C:\MinGW目录下。
Myeclipse8.5+SDK+ADT配置Android开发环境Author----Mr.K工欲善其事必先利其器,Android开发也不例外,使用熟悉的工具搭建开发环境,会给我们带来很多方便,下面则是我使用MyEclipse+SDK+ADT搭建android开发环境的步骤,此方法是离线方式来配置,MyEclipse也提供在线安装配置方式,有兴趣可以试下。
1.计算机操作系统winXP或者Win7(本次使用Win7)2.JDK,确保自己安装JDK配置好环境变量,不多说(本次使用jdk1.6.0_24),在命令行输入java –h显示信息输入java –version显示输入jar显示确保JDK环境变量配置正确。
3.下载安装MyEclipse8.5,本次使用的为myeclipse-8.5.0-win32.exe。
此版本安装时会有两个目录选择,一个为安放MyEclipse本身所需配置(占用磁盘60M左右),另一个存放所需支持插件(占用磁盘1G左右),推荐两个目录使用不同文件夹;确保MyEclipse8.5安装正确,自己写个java的helloworld试试。
4.下载Android SDK和ADT,地址/sdk/index.html找到SDK和ADT压缩包,本次下载的为android-sdk_r18-windows.zip和ADT-21.1.0.zip(注意ADT版本过低的话在MyEclipse中配置SDK的时候会报错提示)。
5.解压SDK,将android-sdk_r18-windows.zip解压开,最好解压到无中文无空格的一个路径下。
运行其中的SDK Manager.exe,勾选其中tools、不同版本android包、和Extras,也可以全部下载下来(会占用几个G的磁盘空间),方便开发不同版本的android 程序(新手菜鸟,各个包下的子项都是做什么的还没搞懂( ⊙o⊙))。
这是一个联网下载的过程,会很慢,要耐心等待。
1.2 MyEclipse开发环境
MyEclipse企业级工作平台(MyEclipse Enterprise Workbench ,简称MyEclipse)是对Eclipse IDE的扩展,也就是所说的插件,利用它我们可以在数据库和J2EE的开发、发布,以及应用程序服务器的整合方面极大的提高工作效率。
它是功能丰富的J2EE集成开发环境,包括了完备的编码、调试、测试和发布功能,完整支持HTML、UML、Web Tools、JSF、CSS、Javascript、SQL、Struts、Hibernate、Spring等技术。
MyEclipse可以简化Web应用开发,并对Struts、Hibernate、Spring等开发框架的广泛应用起到了非常好的促进作用。
1.2.1 MyEclipse简介与下载
MyEclipse是一个专门为Eclipse设计的商业插件和开源插件的完美集合。
MyEclipse为Eclipse提供了一个大量私有和开源的Java工具的集合,MyEclipse目前支持Java Servlet、AJAX、JSP、JSF、Struts、Spring、Hibernate、EJB3、JDBC数据库链接工具等多项功能。
可以说MyEclipse几乎囊括了目前所有主流开源产品的专属Eclipse开发工具,很大程度上解决了各种开源工具的不一致和缺点问题,并大大提高了Java和JSP应用开发的效率。
MyEclipse 的实际价值来自其发布的大量的可视化开发工具和实用组件。
如CCS/JS/HTML/XML的编辑器,帮助创建EJB和Struts项目的向导并产生项目的所有主要的组件如Action/Session Bean/Form等,此外还包含编辑Hibernate配置文件和执行SQL语句的工具。
MyEclipse包含大量由其他组织开发的开源插件,Genuitec增强了这些插件的功能并且撰写了很多使用文档便于开发者学习。
Myeclipse插件对加速Eclipse的流行起到了很重要的作用,并大大简化了复杂Java和JSP应用程序的开发。
Genuitec开发的MyEclipse企业版插件提供更多功能,年费需要几十到几百美元。
简单而言,MyEclipse是Eclipse的插件,也是一款功能强大的JavaEE集成开发环境,支持代码编写、配置、测试以及除错,MyEclipse6.0以前版本需先安装Eclipse。
MyEclipse6.0以后版本安装时不需安装Eclipse。
MyEclipse的官方网站为。
可根据需要购买或者使用试用版的MyEclipse版本。
本节使用的是MyEclipse8.6版本。
1.2.2 MyEclipse安装与使用
1. MyEclipse安装
在下载文件夹中双击文件“myeclipse-8.6.0-win32.exe”即开始安装,具体安装步骤如下:(1)双击“myeclipse-8.6.0-win32.exe”文件,进行参数传送后,弹出如图3-43所示对话框。
当安装MyEclipse的组件准备好后,即弹出如图3-44所示对话框
图3-43 Extracting Installer for MyEclipse Launching
图3-44 “安装”对话框
(2)选择“next”后选定“I accept the terms of license agrement”,如图3-45所示。
图3-45 “选择协议”对话框
(3)选择“next”后,弹出如图3-46所示的对话框,单击Change按钮,可以选择MyEclipse 安装路径,这里我们选用默认路径。
图3-46 选择安装路径
(4)单击“Install”按钮后,开始安装,弹出如图3-47所示安装进度对话框。
图3-47 安装进度对话框
(5)经过几分钟安装后弹出如图3-48所示对话框。
在该对话框中选择工作区路径,可以使用默认值,选择后单击OK按钮。
弹出如图3-49所示MyEclipse开发主界面。
可以使用菜单项对该开发工具进行设置与使用。
图3-48 工作区选择
图3-49 开发主界面
(6)在MyEclipse中配置Tomcat。
选择菜单栏中的“window”|“preferences”选项。
在弹出的对话框左边选择“MyEclipse”|“Servers”|“Integrated Sandbox”|“MyEclipse Tomcat 6”,显示出MyEclipse自带的tomcat 6配置信息,如可以修改“MyEclipse Tomcat 6”的“Port Number:8080”,如图3-50所示。
如果不用MyEclipse自带的tomcat 6,在弹出的对话框左边选择“MyEclipse”|“Servers”|“Tomcat”|“Tomcat 5.x”,如果Tomcat的版本较高,也可以选择6.x,7.x,在对话框右边通过“Browse”找到“Tomcat home directory”,如图3-50所示。
指定Tomcat的路径之后点击OK即可。
图3-50 在MyEclipse中配置Tomcat
图3-51 在MyEclipse中配置Tomcat
2、MyEclipse的使用
(1)选择菜单栏中的“File”|“New”|“Web Project”命令,命名项目名称为/ch03,如图3-52所示。
图3-52 新建项目
(2)选择图3-53中的“Finish”按钮,项目建成,如图3-40所示。
完成后,在workspace 栏会生成一些默认的目录。
src目录:存放java源文件
WebRoot目录:是web应用顶层目录
EMTA-INF目录:存放系统描述信息
WEB-INF目录:由以下部分组成。
lib目录:存放.jar或.zip文件。
web.xml:web应用初始化配置文件。
JSP文件:动态页面的JSP文件。
图3-53 项目界面
(3)在WebRoot目录上单击右键,选择“new”|“JSP(Advanced Templates)”,在弹出的对话框中写一个FileName,如HelloWorld.jsp点击“finish“,一个JSP文件就建好了,如图3-54所示。
图3-54 创建一个JSP文件
(4)在MyEclipse编辑器中进行编程,插入简单的java代码。
找到<body></body>中间的部分。
插入如下代码
<%out.print("JSP Hello World!"); %>
(5)web project的部署
JSP程序可以运行在Tomcat服务器上面。
单击图3-55所示的“Deploy MyEclipse
J2EEProject to Server”的按钮。
在弹出框中选择当前的project name(如ch03),然后点Add,如图3-56所示。
在server中选择Tomcat,点击“Finish”,如图3-57所示。
图3-55 部署web project 图3-56 部署web project ch03
图3-57 在server中选择Tomcat
(6)启动Tomcat
点击刚才那个deploy旁边的“Run/stop/restart MyEclipse”按钮。
选择Tomcat-Start,如图3-58所示。
稍等一下,Tomcat服务启动完毕。
在下方的console中可以看到显示Tomcat启动成功的信息。
如果要在浏览器中运行.jsp页面,Tomcat必须处于启动状态,如图3-59所示。
图3-58启动Tomcat
图3-59 Tomcat已启动
(7)运行HelloWorld.jsp程序。
在菜单栏选择“Run|Run”,如图3-60所示。
在浏览器中输入
http://zh-ffd913c6622a:8080/ch03/HelloWorld.jsp,就可以看到显示的页面了,如图3-61所示。
图3-60 运行JSP程序
图3-61 HelloWorld.jsp的执行结果。