05
фев
Eclipse (@ www.eclipse.org) is an open-source Integrated Development Environment (IDE) supported by IBM. Eclipse is popular for Java application development (Java SE and Java EE) and Android apps. It also supports C/C++, PHP, Python, Perl, and other web project developments via extensible plug-ins. Eclipse is cross-platform and runs under Windows, Linux and macOS.
Eclipse is the most used Java development IDE and knowing Eclipse shortcuts not only improve your productivity but also makes you more efficient. You will have more time for things you like to do.
The various versions are:
To use Eclipse for Java programming, you need to first install Java Development Kit (JDK). Read 'How to Install JDK for Windows'.
Download Eclipse from https://www.eclipse.org/downloads. Under 'Get Eclipse IDE 2019-12' ⇒ Click 'Download Packages'. For beginners, choose the 'Eclipse IDE for Java Developers' and 'Windows 64-bit' (e.g., 'eclipse-java-2019-12-R-win32-x86_64.zip
' - about 201MB) ⇒ Download.
To install Eclipse, simply unzip the downloaded file into a directory of your choice (e.g., 'c:myProject
').
I prefer the zip version, because there is no need to run any installer. Moreover, you can simply delete the entire Eclipse directory when it is no longer needed (without running any un-installer). You are free to move or rename the directory. You can install (unzip) multiple copies of Eclipse in the same machine.
To use Eclipse for Java programming, you need to first install JDK. Read 'How to install JDK for macOS'.
To install Eclipse:
eclipse-java-2019-12-R-macosx-cocoa-x86_64.dmg
')./Applications/eclipse
'. (To confirm!)Eclipse comes with many flavors (See 'Eclipse Packages' @ https://www.eclipse.org/downloads/compare.php):
Nonetheless, you can install any package, and then add more features when needed.
To install Eclipse (e.g, for Java Programming):
eclipse-java-2019-12-R-linux-gtk-x86_64.tar.gz
') in the '~/Downloads
' folder./usr/local
. To run Eclipse, open the '/usr/local/eclipse
' folder and click on the 'Eclipse' icon; or start a 'Terminal', enter 'eclipse'.
Simply start Eclipse. Right-click the Eclipse icon ⇒ Lock to Launcher.
(For older version - If the above don't work) Create a /usr/share/applications/eclipse.desktop
file with the following contents:
Start Eclipse, right-click on the Eclipse icon on launcher ⇒ lock to launcher.
eclipse.exe
' from the Eclipse installed directory.c:myProjecteclipse
for Windows) ⇒ Launch.To create a new Java project:
FirstProject
'.FirstProject
' (or use the 'File' menu) ⇒ New ⇒ Class.Hello
'.public static void main(String[] args)
'.Hello.java
' opens on the editor panel (the center pane). Enter the following codes: Hello.java
' (or choose 'Run' menu) ⇒ Run As ⇒ Java Application.Eclipse performs incremented compilation, as and when a source 'line' is entered. It marked a source line having syntax error with a RED CROSS. Place your cursor at the RED CROSS to view the error message.
Contact Details: Primary Phone, Mobile Number, Pager, Home, Business. EmailsPreview & Sort OptionUser can sort recovered deleted Contact items 'Contacts with attachments, Full Name, Company, File As, Business Fax, Home Phone, Mobile Phone, Categories’. Address: Home, Business, Other. Outlook 2011 mac raw query for messages deleted today. TasksThe tool can repair and restore deleted task items from Outlook data file (PST / OST / BAK) in a single go.
You CANNOT RUN the program if there is any syntax error (marked by a RED CROSS before the filename). Correct all the syntax errors; and RUN the program.
HINTS: In some cases, Eclipse shows a ORANGE LIGHT-BULB (for HINTS) next to the ERROR RED-CROSS (Line 5 in the above diagram). You can click on the LIGHT-BULB to get a list of HINTS to resolve this particular error, which may or may not work!
SYNTAX WARNING: marked by a orange triangular exclaimation sign. Unlike errors, warnings may or may not cause problems. Try to fix these warnings as well. But you can RUN your program with warnings.
At a minimum, you SHOULD browse through Eclipse's 'Workbench User Guide' and 'Java Development User Guide' - accessible via the Eclipse's 'Welcome' page or 'Help' menu. This will save you many agonizing hours trying to figure out how to do somethings later.
Able to use a graphics debugger to debug program is crucial in programming. It could save you countless hours guessing on what went wrong.
The following program computes and prints the factorial of n
(=1*2*3*..*n
). The program, however, has a logical error and produce a wrong answer for n
=20
('The Factorial of 20 is -2102132736
' - a negative number?!).
Let's use the graphic debugger to debug the program.
A breakpoint suspends program execution for you to examine the internal states (e.g., value of variables) of the program. Before starting the debugger, you need to set at least one breakpoint to suspend the execution inside the program. Set a breakpoint at main()
method by double-clicking on the left-margin of the line containing main()
. A blue circle appears in the left-margin indicating a breakpoint is set at that line.
Right click anywhere on the source code (or from the 'Run' menu) ⇒ 'Debug As' ⇒ 'Java Application' ⇒ choose 'Yes' to switch into 'Debug' perspective (A perspective is a particular arrangement of panels to suits a certain development task such as editing or debugging). The program begins execution but suspends its operation at the breakpoint, i.e., the main()
method.
As illustrated in the following diagram, the highlighted line (also pointed to by a blue arrow) indicates the statement to be executed in the next step.
Click the 'Step Over' button (or select 'Step Over' from 'Run' menu) to single-step thru your program. At each of the step, examine the value of the variables (in the 'Variable' panel) and the outputs produced by your program (in the 'Console' Panel), if any. You can also place your cursor at any variable to inspect the content of the variable.
Single-stepping thru the program and watching the values of internal variables and the outputs produced is the ultimate mean in debugging programs - because it is exactly how the computer runs your program!
As mentioned, a breakpoint suspends program execution and let you examine the internal states of the program. To set a breakpoint on a particular statement, double-click the left-margin of that line (or select 'Toggle Breakpoint' from 'Run' menu).
'Resume' continues the program execution, up to the next breakpoint, or till the end of the program.
'Single-step' thru a loop with a large count is time-consuming. You could set a breakpoint at the statement immediately outside the loop (e.g., Line 11 of the above program), and issue 'Resume' to complete the loop.
Alternatively, you can place the cursor on a particular statement, and issue 'Run-To-Line' from the 'Run' menu to continue execution up to the line.
'Terminate' ends the debugging session. Always terminate your current debugging session using 'Terminate' or 'Resume' till the end of the program.
Click the 'Java' perspective icon on the upper-right corner to switch back to the 'Java' perspective for further programming (or 'Window' menu ⇒ Open Perspective ⇒ Java).
Important: I can's stress more that mastering the use of debugger is crucial in programming. Explore the features provided by the debuggers.
Step-Into and Step-Return: To debug a method, you need to use 'Step-Into' to step into the first statement of the method. ('Step-Over' runs the function in a single step without stepping through the statements within the function.) You could use 'Step-Return' to return back to the caller, anywhere within the method. Alternatively, you could set a breakpoint inside a method. Adult adventure games for mac.
Modify the Value of a Variable: You can modify the value of a variable by entering a new value in the 'Variable' panel. This is handy for temporarily modifying the behavior of a program, without changing the source code.
These are the features that I find to be most useful in Eclipse:
sysout
' followed by a ctrl+space (or alt-/) as a shorthand for typing 'System.out.println()
'.-Dfile.encoding=UTF-8
. Commonly used charsets for Unicode are UTF-8, UTF-16 (with BOM), UTF-16BE, UTF-16LE. Other charsets are US-ASCII, ISO-8859-1.clean
' mode, which wipes all the cached data and re-initialize the cache, by running eclipse from command-line with '-clean' argument (i.e., 'eclipse -clean
'). It is useful if something is not working proper, especially if you install a new copy of Eclipse.main()
) in one Java project instead of create a new project for each toy program. To run the desired program, right-click on the source file ⇒ 'Run as' ⇒ 'Java Application'.printf()
or Scanner
(which are available from JDK 1.5), you need to check your compiler settings. Select 'Window' menu ⇒ Preferences ⇒ open the 'Java' node ⇒ select 'Compiler' ⇒ in 'Compiler compliance level' ⇒ select the latest release, which should be '1.5' or above.import
statements for classes. Useful when you copy a large chunk of codes without the corresponding import statements.lib
' directory containing JAR files ('.jar
') (Java Archive - a single-file package of Java classes) and native libraries ('.dll
', '.lib
' for windows, '.a
', '.so
' for Linux and macOS)..jar
') to be included..dll
', '.lib
', '.a
', '.so
'), select 'Native Library' ⇒ 'Location Path' ⇒ 'External Folder'.CLASSPATH
. The native library directories must be included in JRE's property 'java.library.path
', which normally but not necessarily includes all the paths from the PATH
environment variable. Read 'External JAR files and Native Libraries'.jogl
'. The 'User Library' dialog appears.jogl
' ⇒ Add JAR.. ⇒ Navigate to <JOGL_HOME>/lib
, and select 'gluegen-rt.jar
' and 'jogl.jar
'.jogl.jar
' node ⇒ Select 'Native library location: (none)' ⇒ Edit.. ⇒ External Folder.. ⇒ select <JOGL_HOME>/lib
.jogl.jar
' node ⇒ Select 'Javadoc location: (none)'
⇒ Edit.. ⇒ Javadoc in archive ⇒ In 'Archive Path', 'Browse' and select the downloaded JOGL API documentation zip-file ⇒ In 'Path within archive', 'Browse' and expand the zip-file to select the top-level path (if any) ⇒ Validate. Alternatively, you can provide the path to the un-zipped javadocs. This is needed for Eclipse to display javadoc information about classes, fields, and methods.jogl
'.path/scriptname.pl ${resource_loc}
', where ${resource_loc}
is an Eclipse variable that denotes the currently selected resource with absolute path.d:temp${resource_name}.txt
).$JAVA_HOMEjrelibext
.]Suppose that your want to write a Java program, which inputs from a text file called 'xxxx.in
' and outputs to a text file called 'xxxx.out
'. This is a little tricky under Eclipse due to:
xxxx.in
', Notepad will append the '.txt
' to your file and it becomes 'xxxx.in.txt
'. Worse still, the Windows' Explorer, by default, will not show the '.txt
' extension. (The first thing I always do to an alien computer is to change this setting. From 'Tools' menu ⇒ Folder Options.. ⇒ View ⇒ Uncheck 'Hide extensions for known file types'.) You need to put a pair of double quotes around xxxx.in
to override the default '.txt
' extension. This is one good reason not to use Notepad for programming at all. You should use Eclipse to create the text file instead.xxxx.in
' in Eclipse? xxxx.in
' in the base directory of your project, instead of the 'src' or 'bin'.xxxx.out
' created in the package explorer.xxxx.in
' and 'xxxx.out
': right-click ⇒ Open With ⇒ Text Editor.This is a sample JDK 1.5 program for file input/output:
Create the input text file called 'FileIOTest.in
' with the following contents and terminated with a newline:
Eclipse provides a visual GUI builder called 'WindowBuilder' (@ https://www.eclipse.org/windowbuilder), which supports AWT/Swing, SWT (Eclipse's Standard Widget Toolkit - an alternative to JDK's AWT/Swing), XWT, GWT, eRCT.
To install 'WindowBuilder', goto 'Help' ⇒ Install New Software ⇒ In 'Work with', enter 'https://download.eclipse.org/windowbuilder/latest/' (You can find the proper link from 'http://www.eclipse.org/windowbuilder/download.php') ⇒ Check 'WindowBuilder' ⇒ Next ⇒ Next ⇒ Accept the licence ⇒ Finish.
FirstSwingProject
'.JLabel
' and click on the design form. Change the label text to 'Counter: '. Select a 'JTextField' and place it on the design form. Change the text to '0'. Select a 'JButton' and place it on the design form. Change the text label to 'Count'.JButton
to switch into the 'Source' pane, with the event-handler skeleton created. Complete the actionPerformed()
as follows: Add an instance variable called count
as follow: Study the codes generated by Eclipse GUI Builder, as follows, which is just a typical Swing application.
Here.
Here.
Reference: 'Data Tools Platform User Documentation' @ Eclipse Welcome page.
You need to install Eclipse for Java EE, MySQL and MySQL Connector/J Driver. Read 'How to install and get started with MySQL'.
To use Eclipse for MySQL development:
HelloJSP
' ⇒ Finish.HelloJSP
' ⇒ New ⇒ JSP File ⇒ The parent folder shall be 'HelloJSP/WebContent' ⇒ In 'File Name', enter 'Hello
' ⇒ 'Finsih'.<body>..</body>
tags: Hello.jsp
' ⇒ Run As ⇒ Run on Server.HelloServlet
' ⇒ 'Finish'.HelloServlet
' ⇒ New ⇒ Servlet ⇒ In 'Java Package', enter 'hello
'; in 'Class Name', enter 'HelloServlet
' ⇒ Next ⇒ In 'URL Mappings', select 'HelloServlet
', 'Edit' to 'Hello
' ⇒ Next ⇒ In 'Which method stubs would you like to create', check 'Inherited abstract method' and 'doGet' ⇒ Finish.(For Servlet 2.4/2.5 with Tomcat 6) The annotation @WebServlet
is new in Servlet 3.0 and is not supported in Servlet 2.4/2.5. Hence, you need to manually configure the URL for the servlet in the Web Application Deployment Descriptor 'web.xml
' under directory 'WEB-INF
', as follows:
HelloServlet
' project ⇒ 'Run As' ⇒ 'Run on Server' ⇒ Change the URL to 'http://localhost:8080/HelloServlet/sayhello
'.Right-click on the project to be exported ⇒ Export ⇒ WAR File ⇒ In 'Destination', specify the destination directory and filename (the filename shall be the web application name) ⇒ Finish.
webapps
' folder. The war file will be automatically extracted and deployed. The web application name is the war-filename.[TODO]
You can debug a webapp just like standalone application. For example, you can set breakpoints, single-step through the programs, etc.
REFERENCES & RESOURCES
The essential tools for any Java developer, including a Java IDE, a CVS client, Git client, XML Editor, Mylyn, Maven integration and WindowBuilder
Maintained by: Eclipse Mylyn Project
Bug ID | Title | Status |
516739 | Add WindowBuilder to Java package again | NEW |
513809 | [wiring] HttpComponents wiring issue | NEW |
509799 | Symantec reports a Trojan SONAR.AM.C!g24 in eclipse | NEW |
508091 | Duplicate options in Eclipse.ini | NEW |
521514 | Add 'Eclipse News' RSS feed to Java Package | NEW |
522649 | News feed plugin not installed on upgrade installs | NEW |
536469 | Use png with transparent icon in the about dialog of Java EPP (and others if applicable) | NEW |
530698 | Using weka api | NEW |
526611 | win64 version missing | NEW |
498457 | FileNotFoundException : org.eclipse.ui_3.108.0.v20160518-1929.jar | NEW |
489296 | Improve out-of-box experience for non-english locales | NEW |
386806 | New Eclipse Icon not used by Eclipse 4.2 on Windows 7 | NEW |
374170 | bugs when updating software | NEW |
364551 | setup automated tests for Java EPP package | NEW |
414381 | Failed to load the JNI shared library 'C:ogramFilesJavajre6binclientjvm.dll' | NEW |
458646 | Problème démarrage Eclipse | NEW |
355002 | EPP packages need styling | NEW |
473585 | Help system broken after updating from Luna to Mars | NEW |
487713 | FileNotFoundException: introData.xml | NEW |
382232 | Add 'EGit Import' to EPP package with EGit | ASSIGNED |
487722 | Dead link for 'Remote Help': Topic not found | REOPENED |
Bugs listed in italics indicate the bug has been moved to another project.
Bug ID | Title | Status |
382804 | Ctrl+C, Ctrl+V shortcuts don't work while editing Android XML | RESOLVED |
492163 | Add Maven to java package | RESOLVED |
383193 | Taskbar icon doesn't show Android build progress | RESOLVED |
490044 | [Welcome] Adopt Solstice theme for Java package | RESOLVED |
386686 | the Mobile package should include the Mylyn Bugzilla connector | RESOLVED |
365594 | add code recommenders to java package | RESOLVED |
358692 | Eclipse java package crash in Ubuntu 11.0.4 | RESOLVED |
356126 | fix Mylyn repository URLs in EPP packages for Indigo | RESOLVED |
356349 | update Mylyn URLs for Juno | RESOLVED |
357020 | add Mylyn Hudson/Jenkins connector to Java package | RESOLVED |
357332 | Annotations not shown on overview ruler | RESOLVED |
389113 | Unable to Launch Eclipse after download and setup: 'The Eclipse executable launcher was unable to locate its companion shared library.' | RESOLVED |
406246 | zip compression error | RESOLVED |
468598 | Mars RC1 Mac packages are damaged | RESOLVED |
535504 | Open file feature broken in Photon RC2 EPP packages | RESOLVED |
474204 | Include Buildship as part of Java package | RESOLVED |
534617 | [Photon] [java] Add Tip of the Day to the Java Package | RESOLVED |
528429 | m2e to download sources by default | RESOLVED |
194805 | add Error Log view to Java EPP distribution | RESOLVED |
432716 | Consider org.eclipse.recommenders.mylyn.rcp.feature for inclusion into Java package | RESOLVED |
483914 | bug | RESOLVED |
436206 | Re-enable Marketplace Client in Java Package | RESOLVED |
481475 | Scroll lock button being disabled | RESOLVED |
350079 | EGit should be by included in Java package | RESOLVED |
355058 | update repository locations for Juno | RESOLVED |
275767 | [Galileo M7] FileNotFoundException when updating Mylyn | RESOLVED |
275719 | [Galileo M7] packages do not have dropins folder | RESOLVED |
279203 | Add and enable Mylyn update site by default | RESOLVED |
281448 | [update] manager talking to update sites not available | RESOLVED |
549138 | Mylyn cannot be removed from Java IDE package | RESOLVED |
275558 | [Galileo M7] welcome view is not displayed on first startup | RESOLVED |
275523 | [Galileo M7] features appear twice in the about dialog | RESOLVED |
246466 | Missing/extra update sites when installing in either C:program file or C: | RESOLVED |
248976 | 'IDE for Java Developers' package is too restrictive by specifying Java 1.5 as required | RESOLVED |
275520 | [Galileo M7] package does not have any update sites | RESOLVED |
275521 | Improve branding for Galileo java package | RESOLVED |
297341 | EPP web page 'Download Milestone' link points to old builds | RESOLVED |
287566 | error on update after clean install | RESOLVED |
341705 | I tried to load the eclipse environment in Win Vista OS and got problems restoring workbench.. | RESOLVED |
343869 | Add WindowBuilder Core and Swing to the Java package | RESOLVED |
346703 | Inclusion of m2e marketplace on help menu causing confusion | RESOLVED |
348157 | intrusive 'preview?' dialog on startup, from WindowBuilder | RESOLVED |
340312 | Indigo Java package logs lots of output | RESOLVED |
334180 | package contains duplicate (and modified?) bundles | RESOLVED |
313818 | Bugzilla connector does not load on Java 1.5 due to missing java.xml.bind bundle | RESOLVED |
306817 | Cannot update from M5 to Eclipse 3.6 M6 | RESOLVED |
311613 | java IDE / m6 / linux has an EclispeCon splash screen? | RESOLVED |
507104 | Include EclEmma in Java Package | RESOLVED |
507515 | Issue encountered when updating and reinstalling ABAP Development tools on NEON version. | CLOSED |
532067 | Open Bugs | CLOSED |
530726 | Mac OS X(Cocoa)64位下载连接无效 | CLOSED |
515622 | Eclipse will not run | CLOSED |
526343 | Constantly returning error message when opening the program | CLOSED |
501518 | Exception while updating external folders | CLOSED |
521654 | Getting error while starting Apache server | CLOSED |
529170 | MacOs didnt open the program | CLOSED |
548444 | The Java GUI is too big | CLOSED |
497204 | resource in project, but error says not open | CLOSED |
547604 | Can't Install software | CLOSED |
548562 | I am not able to update because of unfound repositories. | CLOSED |
550404 | sgfghg | CLOSED |
551635 | I can't run eclipse without having a bug on it. | CLOSED |
543464 | 2018-12 Installation Error | CLOSED |
543054 | Eclipse crashing while looking at files | CLOSED |
540168 | java 11 | CLOSED |
539041 | Unable to Install | CLOSED |
541760 | Missing Java Developer links for 2018-12 M3 | CLOSED |
542080 | Problems occurred when invoking code from plug-in: 'org.eclipse.ui.views.properties.tabbed'. | CLOSED |
543011 | java.io.FileWriter, the File cannot be deleted | CLOSED |
534760 | Simple compilation fails in Eclipse Oxygen.3a | CLOSED |
457081 | Add Error Reporting to Java Package | CLOSED |
435919 | Add 'Eclipse Code Recommenders' to 'This package includes' list | CLOSED |
435449 | Add org.eclipse.recommenders.snipmatch.rcp.feature to java-package | CLOSED |
436109 | update java package maintainer information | CLOSED |
455363 | Allow users to uninstall features from a package | CLOSED |
461540 | Unarchiving error | CLOSED |
414385 | the eclipsec executable launcher was unable to locate its companion shared library | CLOSED |
384532 | The Eclipse executable launcher was unable to locate its companion shared library | CLOSED |
330226 | Inclusion of m2e | CLOSED |
304968 | LinkageError when trying to use Eclipse to run (PDE) Ant scripts | CLOSED |
349028 | fix provider name for org.eclipse.wb.discovery.* | CLOSED |
353613 | Add EGit 1.1 to java-package | CLOSED |
381216 | Zip file for Java IDE RC1 package requires a password? | CLOSED |
464220 | Bug | CLOSED |
470912 | p2 can't find epp repo for Mars release | CLOSED |
482370 | thanks | CLOSED |
482285 | Mars.1 splash screen does not show progress bar after using console | CLOSED |
484535 | An error removing AppEngine from the project | CLOSED |
494695 | Didn't update from old version | CLOSED |
495806 | Suboptimal 'Visit' link on About Eclipse Features page | CLOSED |
480756 | Switch to root level features to allow users to remove unwanted features | CLOSED |
478619 | Webapp | CLOSED |
476546 | Eclipse Mars.1 RC2 for Java Developers includes CVS cheat sheets but no CVS support | CLOSED |
476553 | Installed Code Recommenders Snipmatch and Mylyn Integration features do not *show* under Installation Details | CLOSED |
477195 | Maintainer/tester information outdated | CLOSED |
477572 | p | CLOSED |
497192 | Eclipse Mars does not open in Windows 10 Pro | CLOSED |
Bugs listed in italics indicate the bug has been moved to another project.
Eclipse (@ www.eclipse.org) is an open-source Integrated Development Environment (IDE) supported by IBM. Eclipse is popular for Java application development (Java SE and Java EE) and Android apps. It also supports C/C++, PHP, Python, Perl, and other web project developments via extensible plug-ins. Eclipse is cross-platform and runs under Windows, Linux and macOS.
Eclipse is the most used Java development IDE and knowing Eclipse shortcuts not only improve your productivity but also makes you more efficient. You will have more time for things you like to do.
The various versions are:
To use Eclipse for Java programming, you need to first install Java Development Kit (JDK). Read 'How to Install JDK for Windows'.
Download Eclipse from https://www.eclipse.org/downloads. Under 'Get Eclipse IDE 2019-12' ⇒ Click 'Download Packages'. For beginners, choose the 'Eclipse IDE for Java Developers' and 'Windows 64-bit' (e.g., 'eclipse-java-2019-12-R-win32-x86_64.zip
' - about 201MB) ⇒ Download.
To install Eclipse, simply unzip the downloaded file into a directory of your choice (e.g., 'c:myProject
').
I prefer the zip version, because there is no need to run any installer. Moreover, you can simply delete the entire Eclipse directory when it is no longer needed (without running any un-installer). You are free to move or rename the directory. You can install (unzip) multiple copies of Eclipse in the same machine.
To use Eclipse for Java programming, you need to first install JDK. Read 'How to install JDK for macOS'.
To install Eclipse:
eclipse-java-2019-12-R-macosx-cocoa-x86_64.dmg
')./Applications/eclipse
'. (To confirm!)Eclipse comes with many flavors (See 'Eclipse Packages' @ https://www.eclipse.org/downloads/compare.php):
Nonetheless, you can install any package, and then add more features when needed.
To install Eclipse (e.g, for Java Programming):
eclipse-java-2019-12-R-linux-gtk-x86_64.tar.gz
') in the '~/Downloads
' folder./usr/local
. To run Eclipse, open the '/usr/local/eclipse
' folder and click on the 'Eclipse' icon; or start a 'Terminal', enter 'eclipse'.
Simply start Eclipse. Right-click the Eclipse icon ⇒ Lock to Launcher.
(For older version - If the above don't work) Create a /usr/share/applications/eclipse.desktop
file with the following contents:
Start Eclipse, right-click on the Eclipse icon on launcher ⇒ lock to launcher.
eclipse.exe
' from the Eclipse installed directory.c:myProjecteclipse
for Windows) ⇒ Launch.To create a new Java project:
FirstProject
'.FirstProject
' (or use the 'File' menu) ⇒ New ⇒ Class.Hello
'.public static void main(String[] args)
'.Hello.java
' opens on the editor panel (the center pane). Enter the following codes: Hello.java
' (or choose 'Run' menu) ⇒ Run As ⇒ Java Application.Eclipse performs incremented compilation, as and when a source 'line' is entered. It marked a source line having syntax error with a RED CROSS. Place your cursor at the RED CROSS to view the error message.
Contact Details: Primary Phone, Mobile Number, Pager, Home, Business. EmailsPreview & Sort OptionUser can sort recovered deleted Contact items 'Contacts with attachments, Full Name, Company, File As, Business Fax, Home Phone, Mobile Phone, Categories’. Address: Home, Business, Other. Outlook 2011 mac raw query for messages deleted today. TasksThe tool can repair and restore deleted task items from Outlook data file (PST / OST / BAK) in a single go.
You CANNOT RUN the program if there is any syntax error (marked by a RED CROSS before the filename). Correct all the syntax errors; and RUN the program.
HINTS: In some cases, Eclipse shows a ORANGE LIGHT-BULB (for HINTS) next to the ERROR RED-CROSS (Line 5 in the above diagram). You can click on the LIGHT-BULB to get a list of HINTS to resolve this particular error, which may or may not work!
SYNTAX WARNING: marked by a orange triangular exclaimation sign. Unlike errors, warnings may or may not cause problems. Try to fix these warnings as well. But you can RUN your program with warnings.
At a minimum, you SHOULD browse through Eclipse's 'Workbench User Guide' and 'Java Development User Guide' - accessible via the Eclipse's 'Welcome' page or 'Help' menu. This will save you many agonizing hours trying to figure out how to do somethings later.
Able to use a graphics debugger to debug program is crucial in programming. It could save you countless hours guessing on what went wrong.
The following program computes and prints the factorial of n
(=1*2*3*..*n
). The program, however, has a logical error and produce a wrong answer for n
=20
('The Factorial of 20 is -2102132736
' - a negative number?!).
Let's use the graphic debugger to debug the program.
A breakpoint suspends program execution for you to examine the internal states (e.g., value of variables) of the program. Before starting the debugger, you need to set at least one breakpoint to suspend the execution inside the program. Set a breakpoint at main()
method by double-clicking on the left-margin of the line containing main()
. A blue circle appears in the left-margin indicating a breakpoint is set at that line.
Right click anywhere on the source code (or from the 'Run' menu) ⇒ 'Debug As' ⇒ 'Java Application' ⇒ choose 'Yes' to switch into 'Debug' perspective (A perspective is a particular arrangement of panels to suits a certain development task such as editing or debugging). The program begins execution but suspends its operation at the breakpoint, i.e., the main()
method.
As illustrated in the following diagram, the highlighted line (also pointed to by a blue arrow) indicates the statement to be executed in the next step.
Click the 'Step Over' button (or select 'Step Over' from 'Run' menu) to single-step thru your program. At each of the step, examine the value of the variables (in the 'Variable' panel) and the outputs produced by your program (in the 'Console' Panel), if any. You can also place your cursor at any variable to inspect the content of the variable.
Single-stepping thru the program and watching the values of internal variables and the outputs produced is the ultimate mean in debugging programs - because it is exactly how the computer runs your program!
As mentioned, a breakpoint suspends program execution and let you examine the internal states of the program. To set a breakpoint on a particular statement, double-click the left-margin of that line (or select 'Toggle Breakpoint' from 'Run' menu).
'Resume' continues the program execution, up to the next breakpoint, or till the end of the program.
'Single-step' thru a loop with a large count is time-consuming. You could set a breakpoint at the statement immediately outside the loop (e.g., Line 11 of the above program), and issue 'Resume' to complete the loop.
Alternatively, you can place the cursor on a particular statement, and issue 'Run-To-Line' from the 'Run' menu to continue execution up to the line.
'Terminate' ends the debugging session. Always terminate your current debugging session using 'Terminate' or 'Resume' till the end of the program.
Click the 'Java' perspective icon on the upper-right corner to switch back to the 'Java' perspective for further programming (or 'Window' menu ⇒ Open Perspective ⇒ Java).
Important: I can's stress more that mastering the use of debugger is crucial in programming. Explore the features provided by the debuggers.
Step-Into and Step-Return: To debug a method, you need to use 'Step-Into' to step into the first statement of the method. ('Step-Over' runs the function in a single step without stepping through the statements within the function.) You could use 'Step-Return' to return back to the caller, anywhere within the method. Alternatively, you could set a breakpoint inside a method. Adult adventure games for mac.
Modify the Value of a Variable: You can modify the value of a variable by entering a new value in the 'Variable' panel. This is handy for temporarily modifying the behavior of a program, without changing the source code.
These are the features that I find to be most useful in Eclipse:
sysout
' followed by a ctrl+space (or alt-/) as a shorthand for typing 'System.out.println()
'.-Dfile.encoding=UTF-8
. Commonly used charsets for Unicode are UTF-8, UTF-16 (with BOM), UTF-16BE, UTF-16LE. Other charsets are US-ASCII, ISO-8859-1.clean
' mode, which wipes all the cached data and re-initialize the cache, by running eclipse from command-line with '-clean' argument (i.e., 'eclipse -clean
'). It is useful if something is not working proper, especially if you install a new copy of Eclipse.main()
) in one Java project instead of create a new project for each toy program. To run the desired program, right-click on the source file ⇒ 'Run as' ⇒ 'Java Application'.printf()
or Scanner
(which are available from JDK 1.5), you need to check your compiler settings. Select 'Window' menu ⇒ Preferences ⇒ open the 'Java' node ⇒ select 'Compiler' ⇒ in 'Compiler compliance level' ⇒ select the latest release, which should be '1.5' or above.import
statements for classes. Useful when you copy a large chunk of codes without the corresponding import statements.lib
' directory containing JAR files ('.jar
') (Java Archive - a single-file package of Java classes) and native libraries ('.dll
', '.lib
' for windows, '.a
', '.so
' for Linux and macOS)..jar
') to be included..dll
', '.lib
', '.a
', '.so
'), select 'Native Library' ⇒ 'Location Path' ⇒ 'External Folder'.CLASSPATH
. The native library directories must be included in JRE's property 'java.library.path
', which normally but not necessarily includes all the paths from the PATH
environment variable. Read 'External JAR files and Native Libraries'.jogl
'. The 'User Library' dialog appears.jogl
' ⇒ Add JAR.. ⇒ Navigate to <JOGL_HOME>/lib
, and select 'gluegen-rt.jar
' and 'jogl.jar
'.jogl.jar
' node ⇒ Select 'Native library location: (none)' ⇒ Edit.. ⇒ External Folder.. ⇒ select <JOGL_HOME>/lib
.jogl.jar
' node ⇒ Select 'Javadoc location: (none)'
⇒ Edit.. ⇒ Javadoc in archive ⇒ In 'Archive Path', 'Browse' and select the downloaded JOGL API documentation zip-file ⇒ In 'Path within archive', 'Browse' and expand the zip-file to select the top-level path (if any) ⇒ Validate. Alternatively, you can provide the path to the un-zipped javadocs. This is needed for Eclipse to display javadoc information about classes, fields, and methods.jogl
'.path/scriptname.pl ${resource_loc}
', where ${resource_loc}
is an Eclipse variable that denotes the currently selected resource with absolute path.d:temp${resource_name}.txt
).$JAVA_HOMEjrelibext
.]Suppose that your want to write a Java program, which inputs from a text file called 'xxxx.in
' and outputs to a text file called 'xxxx.out
'. This is a little tricky under Eclipse due to:
xxxx.in
', Notepad will append the '.txt
' to your file and it becomes 'xxxx.in.txt
'. Worse still, the Windows' Explorer, by default, will not show the '.txt
' extension. (The first thing I always do to an alien computer is to change this setting. From 'Tools' menu ⇒ Folder Options.. ⇒ View ⇒ Uncheck 'Hide extensions for known file types'.) You need to put a pair of double quotes around xxxx.in
to override the default '.txt
' extension. This is one good reason not to use Notepad for programming at all. You should use Eclipse to create the text file instead.xxxx.in
' in Eclipse? xxxx.in
' in the base directory of your project, instead of the 'src' or 'bin'.xxxx.out
' created in the package explorer.xxxx.in
' and 'xxxx.out
': right-click ⇒ Open With ⇒ Text Editor.This is a sample JDK 1.5 program for file input/output:
Create the input text file called 'FileIOTest.in
' with the following contents and terminated with a newline:
Eclipse provides a visual GUI builder called 'WindowBuilder' (@ https://www.eclipse.org/windowbuilder), which supports AWT/Swing, SWT (Eclipse's Standard Widget Toolkit - an alternative to JDK's AWT/Swing), XWT, GWT, eRCT.
To install 'WindowBuilder', goto 'Help' ⇒ Install New Software ⇒ In 'Work with', enter 'https://download.eclipse.org/windowbuilder/latest/' (You can find the proper link from 'http://www.eclipse.org/windowbuilder/download.php') ⇒ Check 'WindowBuilder' ⇒ Next ⇒ Next ⇒ Accept the licence ⇒ Finish.
FirstSwingProject
'.JLabel
' and click on the design form. Change the label text to 'Counter: '. Select a 'JTextField' and place it on the design form. Change the text to '0'. Select a 'JButton' and place it on the design form. Change the text label to 'Count'.JButton
to switch into the 'Source' pane, with the event-handler skeleton created. Complete the actionPerformed()
as follows: Add an instance variable called count
as follow: Study the codes generated by Eclipse GUI Builder, as follows, which is just a typical Swing application.
Here.
Here.
Reference: 'Data Tools Platform User Documentation' @ Eclipse Welcome page.
You need to install Eclipse for Java EE, MySQL and MySQL Connector/J Driver. Read 'How to install and get started with MySQL'.
To use Eclipse for MySQL development:
HelloJSP
' ⇒ Finish.HelloJSP
' ⇒ New ⇒ JSP File ⇒ The parent folder shall be 'HelloJSP/WebContent' ⇒ In 'File Name', enter 'Hello
' ⇒ 'Finsih'.<body>..</body>
tags: Hello.jsp
' ⇒ Run As ⇒ Run on Server.HelloServlet
' ⇒ 'Finish'.HelloServlet
' ⇒ New ⇒ Servlet ⇒ In 'Java Package', enter 'hello
'; in 'Class Name', enter 'HelloServlet
' ⇒ Next ⇒ In 'URL Mappings', select 'HelloServlet
', 'Edit' to 'Hello
' ⇒ Next ⇒ In 'Which method stubs would you like to create', check 'Inherited abstract method' and 'doGet' ⇒ Finish.(For Servlet 2.4/2.5 with Tomcat 6) The annotation @WebServlet
is new in Servlet 3.0 and is not supported in Servlet 2.4/2.5. Hence, you need to manually configure the URL for the servlet in the Web Application Deployment Descriptor 'web.xml
' under directory 'WEB-INF
', as follows:
HelloServlet
' project ⇒ 'Run As' ⇒ 'Run on Server' ⇒ Change the URL to 'http://localhost:8080/HelloServlet/sayhello
'.Right-click on the project to be exported ⇒ Export ⇒ WAR File ⇒ In 'Destination', specify the destination directory and filename (the filename shall be the web application name) ⇒ Finish.
webapps
' folder. The war file will be automatically extracted and deployed. The web application name is the war-filename.[TODO]
You can debug a webapp just like standalone application. For example, you can set breakpoints, single-step through the programs, etc.
REFERENCES & RESOURCES
The essential tools for any Java developer, including a Java IDE, a CVS client, Git client, XML Editor, Mylyn, Maven integration and WindowBuilder
Maintained by: Eclipse Mylyn Project
Bug ID | Title | Status |
516739 | Add WindowBuilder to Java package again | NEW |
513809 | [wiring] HttpComponents wiring issue | NEW |
509799 | Symantec reports a Trojan SONAR.AM.C!g24 in eclipse | NEW |
508091 | Duplicate options in Eclipse.ini | NEW |
521514 | Add 'Eclipse News' RSS feed to Java Package | NEW |
522649 | News feed plugin not installed on upgrade installs | NEW |
536469 | Use png with transparent icon in the about dialog of Java EPP (and others if applicable) | NEW |
530698 | Using weka api | NEW |
526611 | win64 version missing | NEW |
498457 | FileNotFoundException : org.eclipse.ui_3.108.0.v20160518-1929.jar | NEW |
489296 | Improve out-of-box experience for non-english locales | NEW |
386806 | New Eclipse Icon not used by Eclipse 4.2 on Windows 7 | NEW |
374170 | bugs when updating software | NEW |
364551 | setup automated tests for Java EPP package | NEW |
414381 | Failed to load the JNI shared library 'C:ogramFilesJavajre6binclientjvm.dll' | NEW |
458646 | Problème démarrage Eclipse | NEW |
355002 | EPP packages need styling | NEW |
473585 | Help system broken after updating from Luna to Mars | NEW |
487713 | FileNotFoundException: introData.xml | NEW |
382232 | Add 'EGit Import' to EPP package with EGit | ASSIGNED |
487722 | Dead link for 'Remote Help': Topic not found | REOPENED |
Bugs listed in italics indicate the bug has been moved to another project.
Bug ID | Title | Status |
382804 | Ctrl+C, Ctrl+V shortcuts don't work while editing Android XML | RESOLVED |
492163 | Add Maven to java package | RESOLVED |
383193 | Taskbar icon doesn't show Android build progress | RESOLVED |
490044 | [Welcome] Adopt Solstice theme for Java package | RESOLVED |
386686 | the Mobile package should include the Mylyn Bugzilla connector | RESOLVED |
365594 | add code recommenders to java package | RESOLVED |
358692 | Eclipse java package crash in Ubuntu 11.0.4 | RESOLVED |
356126 | fix Mylyn repository URLs in EPP packages for Indigo | RESOLVED |
356349 | update Mylyn URLs for Juno | RESOLVED |
357020 | add Mylyn Hudson/Jenkins connector to Java package | RESOLVED |
357332 | Annotations not shown on overview ruler | RESOLVED |
389113 | Unable to Launch Eclipse after download and setup: 'The Eclipse executable launcher was unable to locate its companion shared library.' | RESOLVED |
406246 | zip compression error | RESOLVED |
468598 | Mars RC1 Mac packages are damaged | RESOLVED |
535504 | Open file feature broken in Photon RC2 EPP packages | RESOLVED |
474204 | Include Buildship as part of Java package | RESOLVED |
534617 | [Photon] [java] Add Tip of the Day to the Java Package | RESOLVED |
528429 | m2e to download sources by default | RESOLVED |
194805 | add Error Log view to Java EPP distribution | RESOLVED |
432716 | Consider org.eclipse.recommenders.mylyn.rcp.feature for inclusion into Java package | RESOLVED |
483914 | bug | RESOLVED |
436206 | Re-enable Marketplace Client in Java Package | RESOLVED |
481475 | Scroll lock button being disabled | RESOLVED |
350079 | EGit should be by included in Java package | RESOLVED |
355058 | update repository locations for Juno | RESOLVED |
275767 | [Galileo M7] FileNotFoundException when updating Mylyn | RESOLVED |
275719 | [Galileo M7] packages do not have dropins folder | RESOLVED |
279203 | Add and enable Mylyn update site by default | RESOLVED |
281448 | [update] manager talking to update sites not available | RESOLVED |
549138 | Mylyn cannot be removed from Java IDE package | RESOLVED |
275558 | [Galileo M7] welcome view is not displayed on first startup | RESOLVED |
275523 | [Galileo M7] features appear twice in the about dialog | RESOLVED |
246466 | Missing/extra update sites when installing in either C:program file or C: | RESOLVED |
248976 | 'IDE for Java Developers' package is too restrictive by specifying Java 1.5 as required | RESOLVED |
275520 | [Galileo M7] package does not have any update sites | RESOLVED |
275521 | Improve branding for Galileo java package | RESOLVED |
297341 | EPP web page 'Download Milestone' link points to old builds | RESOLVED |
287566 | error on update after clean install | RESOLVED |
341705 | I tried to load the eclipse environment in Win Vista OS and got problems restoring workbench.. | RESOLVED |
343869 | Add WindowBuilder Core and Swing to the Java package | RESOLVED |
346703 | Inclusion of m2e marketplace on help menu causing confusion | RESOLVED |
348157 | intrusive 'preview?' dialog on startup, from WindowBuilder | RESOLVED |
340312 | Indigo Java package logs lots of output | RESOLVED |
334180 | package contains duplicate (and modified?) bundles | RESOLVED |
313818 | Bugzilla connector does not load on Java 1.5 due to missing java.xml.bind bundle | RESOLVED |
306817 | Cannot update from M5 to Eclipse 3.6 M6 | RESOLVED |
311613 | java IDE / m6 / linux has an EclispeCon splash screen? | RESOLVED |
507104 | Include EclEmma in Java Package | RESOLVED |
507515 | Issue encountered when updating and reinstalling ABAP Development tools on NEON version. | CLOSED |
532067 | Open Bugs | CLOSED |
530726 | Mac OS X(Cocoa)64位下载连接无效 | CLOSED |
515622 | Eclipse will not run | CLOSED |
526343 | Constantly returning error message when opening the program | CLOSED |
501518 | Exception while updating external folders | CLOSED |
521654 | Getting error while starting Apache server | CLOSED |
529170 | MacOs didnt open the program | CLOSED |
548444 | The Java GUI is too big | CLOSED |
497204 | resource in project, but error says not open | CLOSED |
547604 | Can't Install software | CLOSED |
548562 | I am not able to update because of unfound repositories. | CLOSED |
550404 | sgfghg | CLOSED |
551635 | I can't run eclipse without having a bug on it. | CLOSED |
543464 | 2018-12 Installation Error | CLOSED |
543054 | Eclipse crashing while looking at files | CLOSED |
540168 | java 11 | CLOSED |
539041 | Unable to Install | CLOSED |
541760 | Missing Java Developer links for 2018-12 M3 | CLOSED |
542080 | Problems occurred when invoking code from plug-in: 'org.eclipse.ui.views.properties.tabbed'. | CLOSED |
543011 | java.io.FileWriter, the File cannot be deleted | CLOSED |
534760 | Simple compilation fails in Eclipse Oxygen.3a | CLOSED |
457081 | Add Error Reporting to Java Package | CLOSED |
435919 | Add 'Eclipse Code Recommenders' to 'This package includes' list | CLOSED |
435449 | Add org.eclipse.recommenders.snipmatch.rcp.feature to java-package | CLOSED |
436109 | update java package maintainer information | CLOSED |
455363 | Allow users to uninstall features from a package | CLOSED |
461540 | Unarchiving error | CLOSED |
414385 | the eclipsec executable launcher was unable to locate its companion shared library | CLOSED |
384532 | The Eclipse executable launcher was unable to locate its companion shared library | CLOSED |
330226 | Inclusion of m2e | CLOSED |
304968 | LinkageError when trying to use Eclipse to run (PDE) Ant scripts | CLOSED |
349028 | fix provider name for org.eclipse.wb.discovery.* | CLOSED |
353613 | Add EGit 1.1 to java-package | CLOSED |
381216 | Zip file for Java IDE RC1 package requires a password? | CLOSED |
464220 | Bug | CLOSED |
470912 | p2 can't find epp repo for Mars release | CLOSED |
482370 | thanks | CLOSED |
482285 | Mars.1 splash screen does not show progress bar after using console | CLOSED |
484535 | An error removing AppEngine from the project | CLOSED |
494695 | Didn't update from old version | CLOSED |
495806 | Suboptimal 'Visit' link on About Eclipse Features page | CLOSED |
480756 | Switch to root level features to allow users to remove unwanted features | CLOSED |
478619 | Webapp | CLOSED |
476546 | Eclipse Mars.1 RC2 for Java Developers includes CVS cheat sheets but no CVS support | CLOSED |
476553 | Installed Code Recommenders Snipmatch and Mylyn Integration features do not *show* under Installation Details | CLOSED |
477195 | Maintainer/tester information outdated | CLOSED |
477572 | p | CLOSED |
497192 | Eclipse Mars does not open in Windows 10 Pro | CLOSED |
Bugs listed in italics indicate the bug has been moved to another project.
Eclipse (@ www.eclipse.org) is an open-source Integrated Development Environment (IDE) supported by IBM. Eclipse is popular for Java application development (Java SE and Java EE) and Android apps. It also supports C/C++, PHP, Python, Perl, and other web project developments via extensible plug-ins. Eclipse is cross-platform and runs under Windows, Linux and macOS.
Eclipse is the most used Java development IDE and knowing Eclipse shortcuts not only improve your productivity but also makes you more efficient. You will have more time for things you like to do.
The various versions are:
To use Eclipse for Java programming, you need to first install Java Development Kit (JDK). Read 'How to Install JDK for Windows'.
Download Eclipse from https://www.eclipse.org/downloads. Under 'Get Eclipse IDE 2019-12' ⇒ Click 'Download Packages'. For beginners, choose the 'Eclipse IDE for Java Developers' and 'Windows 64-bit' (e.g., 'eclipse-java-2019-12-R-win32-x86_64.zip
' - about 201MB) ⇒ Download.
To install Eclipse, simply unzip the downloaded file into a directory of your choice (e.g., 'c:myProject
').
I prefer the zip version, because there is no need to run any installer. Moreover, you can simply delete the entire Eclipse directory when it is no longer needed (without running any un-installer). You are free to move or rename the directory. You can install (unzip) multiple copies of Eclipse in the same machine.
To use Eclipse for Java programming, you need to first install JDK. Read 'How to install JDK for macOS'.
To install Eclipse:
eclipse-java-2019-12-R-macosx-cocoa-x86_64.dmg
')./Applications/eclipse
'. (To confirm!)Eclipse comes with many flavors (See 'Eclipse Packages' @ https://www.eclipse.org/downloads/compare.php):
Nonetheless, you can install any package, and then add more features when needed.
To install Eclipse (e.g, for Java Programming):
eclipse-java-2019-12-R-linux-gtk-x86_64.tar.gz
') in the '~/Downloads
' folder./usr/local
. To run Eclipse, open the '/usr/local/eclipse
' folder and click on the 'Eclipse' icon; or start a 'Terminal', enter 'eclipse'.
Simply start Eclipse. Right-click the Eclipse icon ⇒ Lock to Launcher.
(For older version - If the above don't work) Create a /usr/share/applications/eclipse.desktop
file with the following contents:
Start Eclipse, right-click on the Eclipse icon on launcher ⇒ lock to launcher.
eclipse.exe
' from the Eclipse installed directory.c:myProjecteclipse
for Windows) ⇒ Launch.To create a new Java project:
FirstProject
'.FirstProject
' (or use the 'File' menu) ⇒ New ⇒ Class.Hello
'.public static void main(String[] args)
'.Hello.java
' opens on the editor panel (the center pane). Enter the following codes: Hello.java
' (or choose 'Run' menu) ⇒ Run As ⇒ Java Application.Eclipse performs incremented compilation, as and when a source 'line' is entered. It marked a source line having syntax error with a RED CROSS. Place your cursor at the RED CROSS to view the error message.
Contact Details: Primary Phone, Mobile Number, Pager, Home, Business. EmailsPreview & Sort OptionUser can sort recovered deleted Contact items 'Contacts with attachments, Full Name, Company, File As, Business Fax, Home Phone, Mobile Phone, Categories’. Address: Home, Business, Other. Outlook 2011 mac raw query for messages deleted today. TasksThe tool can repair and restore deleted task items from Outlook data file (PST / OST / BAK) in a single go.
You CANNOT RUN the program if there is any syntax error (marked by a RED CROSS before the filename). Correct all the syntax errors; and RUN the program.
HINTS: In some cases, Eclipse shows a ORANGE LIGHT-BULB (for HINTS) next to the ERROR RED-CROSS (Line 5 in the above diagram). You can click on the LIGHT-BULB to get a list of HINTS to resolve this particular error, which may or may not work!
SYNTAX WARNING: marked by a orange triangular exclaimation sign. Unlike errors, warnings may or may not cause problems. Try to fix these warnings as well. But you can RUN your program with warnings.
At a minimum, you SHOULD browse through Eclipse's 'Workbench User Guide' and 'Java Development User Guide' - accessible via the Eclipse's 'Welcome' page or 'Help' menu. This will save you many agonizing hours trying to figure out how to do somethings later.
Able to use a graphics debugger to debug program is crucial in programming. It could save you countless hours guessing on what went wrong.
The following program computes and prints the factorial of n
(=1*2*3*..*n
). The program, however, has a logical error and produce a wrong answer for n
=20
('The Factorial of 20 is -2102132736
' - a negative number?!).
Let's use the graphic debugger to debug the program.
A breakpoint suspends program execution for you to examine the internal states (e.g., value of variables) of the program. Before starting the debugger, you need to set at least one breakpoint to suspend the execution inside the program. Set a breakpoint at main()
method by double-clicking on the left-margin of the line containing main()
. A blue circle appears in the left-margin indicating a breakpoint is set at that line.
Right click anywhere on the source code (or from the 'Run' menu) ⇒ 'Debug As' ⇒ 'Java Application' ⇒ choose 'Yes' to switch into 'Debug' perspective (A perspective is a particular arrangement of panels to suits a certain development task such as editing or debugging). The program begins execution but suspends its operation at the breakpoint, i.e., the main()
method.
As illustrated in the following diagram, the highlighted line (also pointed to by a blue arrow) indicates the statement to be executed in the next step.
Click the 'Step Over' button (or select 'Step Over' from 'Run' menu) to single-step thru your program. At each of the step, examine the value of the variables (in the 'Variable' panel) and the outputs produced by your program (in the 'Console' Panel), if any. You can also place your cursor at any variable to inspect the content of the variable.
Single-stepping thru the program and watching the values of internal variables and the outputs produced is the ultimate mean in debugging programs - because it is exactly how the computer runs your program!
As mentioned, a breakpoint suspends program execution and let you examine the internal states of the program. To set a breakpoint on a particular statement, double-click the left-margin of that line (or select 'Toggle Breakpoint' from 'Run' menu).
'Resume' continues the program execution, up to the next breakpoint, or till the end of the program.
'Single-step' thru a loop with a large count is time-consuming. You could set a breakpoint at the statement immediately outside the loop (e.g., Line 11 of the above program), and issue 'Resume' to complete the loop.
Alternatively, you can place the cursor on a particular statement, and issue 'Run-To-Line' from the 'Run' menu to continue execution up to the line.
'Terminate' ends the debugging session. Always terminate your current debugging session using 'Terminate' or 'Resume' till the end of the program.
Click the 'Java' perspective icon on the upper-right corner to switch back to the 'Java' perspective for further programming (or 'Window' menu ⇒ Open Perspective ⇒ Java).
Important: I can's stress more that mastering the use of debugger is crucial in programming. Explore the features provided by the debuggers.
Step-Into and Step-Return: To debug a method, you need to use 'Step-Into' to step into the first statement of the method. ('Step-Over' runs the function in a single step without stepping through the statements within the function.) You could use 'Step-Return' to return back to the caller, anywhere within the method. Alternatively, you could set a breakpoint inside a method. Adult adventure games for mac.
Modify the Value of a Variable: You can modify the value of a variable by entering a new value in the 'Variable' panel. This is handy for temporarily modifying the behavior of a program, without changing the source code.
These are the features that I find to be most useful in Eclipse:
sysout
' followed by a ctrl+space (or alt-/) as a shorthand for typing 'System.out.println()
'.-Dfile.encoding=UTF-8
. Commonly used charsets for Unicode are UTF-8, UTF-16 (with BOM), UTF-16BE, UTF-16LE. Other charsets are US-ASCII, ISO-8859-1.clean
' mode, which wipes all the cached data and re-initialize the cache, by running eclipse from command-line with '-clean' argument (i.e., 'eclipse -clean
'). It is useful if something is not working proper, especially if you install a new copy of Eclipse.main()
) in one Java project instead of create a new project for each toy program. To run the desired program, right-click on the source file ⇒ 'Run as' ⇒ 'Java Application'.printf()
or Scanner
(which are available from JDK 1.5), you need to check your compiler settings. Select 'Window' menu ⇒ Preferences ⇒ open the 'Java' node ⇒ select 'Compiler' ⇒ in 'Compiler compliance level' ⇒ select the latest release, which should be '1.5' or above.import
statements for classes. Useful when you copy a large chunk of codes without the corresponding import statements.lib
' directory containing JAR files ('.jar
') (Java Archive - a single-file package of Java classes) and native libraries ('.dll
', '.lib
' for windows, '.a
', '.so
' for Linux and macOS)..jar
') to be included..dll
', '.lib
', '.a
', '.so
'), select 'Native Library' ⇒ 'Location Path' ⇒ 'External Folder'.CLASSPATH
. The native library directories must be included in JRE's property 'java.library.path
', which normally but not necessarily includes all the paths from the PATH
environment variable. Read 'External JAR files and Native Libraries'.jogl
'. The 'User Library' dialog appears.jogl
' ⇒ Add JAR.. ⇒ Navigate to <JOGL_HOME>/lib
, and select 'gluegen-rt.jar
' and 'jogl.jar
'.jogl.jar
' node ⇒ Select 'Native library location: (none)' ⇒ Edit.. ⇒ External Folder.. ⇒ select <JOGL_HOME>/lib
.jogl.jar
' node ⇒ Select 'Javadoc location: (none)'
⇒ Edit.. ⇒ Javadoc in archive ⇒ In 'Archive Path', 'Browse' and select the downloaded JOGL API documentation zip-file ⇒ In 'Path within archive', 'Browse' and expand the zip-file to select the top-level path (if any) ⇒ Validate. Alternatively, you can provide the path to the un-zipped javadocs. This is needed for Eclipse to display javadoc information about classes, fields, and methods.jogl
'.path/scriptname.pl ${resource_loc}
', where ${resource_loc}
is an Eclipse variable that denotes the currently selected resource with absolute path.d:temp${resource_name}.txt
).$JAVA_HOMEjrelibext
.]Suppose that your want to write a Java program, which inputs from a text file called 'xxxx.in
' and outputs to a text file called 'xxxx.out
'. This is a little tricky under Eclipse due to:
xxxx.in
', Notepad will append the '.txt
' to your file and it becomes 'xxxx.in.txt
'. Worse still, the Windows' Explorer, by default, will not show the '.txt
' extension. (The first thing I always do to an alien computer is to change this setting. From 'Tools' menu ⇒ Folder Options.. ⇒ View ⇒ Uncheck 'Hide extensions for known file types'.) You need to put a pair of double quotes around xxxx.in
to override the default '.txt
' extension. This is one good reason not to use Notepad for programming at all. You should use Eclipse to create the text file instead.xxxx.in
' in Eclipse? xxxx.in
' in the base directory of your project, instead of the 'src' or 'bin'.xxxx.out
' created in the package explorer.xxxx.in
' and 'xxxx.out
': right-click ⇒ Open With ⇒ Text Editor.This is a sample JDK 1.5 program for file input/output:
Create the input text file called 'FileIOTest.in
' with the following contents and terminated with a newline:
Eclipse provides a visual GUI builder called 'WindowBuilder' (@ https://www.eclipse.org/windowbuilder), which supports AWT/Swing, SWT (Eclipse's Standard Widget Toolkit - an alternative to JDK's AWT/Swing), XWT, GWT, eRCT.
To install 'WindowBuilder', goto 'Help' ⇒ Install New Software ⇒ In 'Work with', enter 'https://download.eclipse.org/windowbuilder/latest/' (You can find the proper link from 'http://www.eclipse.org/windowbuilder/download.php') ⇒ Check 'WindowBuilder' ⇒ Next ⇒ Next ⇒ Accept the licence ⇒ Finish.
FirstSwingProject
'.JLabel
' and click on the design form. Change the label text to 'Counter: '. Select a 'JTextField' and place it on the design form. Change the text to '0'. Select a 'JButton' and place it on the design form. Change the text label to 'Count'.JButton
to switch into the 'Source' pane, with the event-handler skeleton created. Complete the actionPerformed()
as follows: Add an instance variable called count
as follow: Study the codes generated by Eclipse GUI Builder, as follows, which is just a typical Swing application.
Here.
Here.
Reference: 'Data Tools Platform User Documentation' @ Eclipse Welcome page.
You need to install Eclipse for Java EE, MySQL and MySQL Connector/J Driver. Read 'How to install and get started with MySQL'.
To use Eclipse for MySQL development:
HelloJSP
' ⇒ Finish.HelloJSP
' ⇒ New ⇒ JSP File ⇒ The parent folder shall be 'HelloJSP/WebContent' ⇒ In 'File Name', enter 'Hello
' ⇒ 'Finsih'.<body>..</body>
tags: Hello.jsp
' ⇒ Run As ⇒ Run on Server.HelloServlet
' ⇒ 'Finish'.HelloServlet
' ⇒ New ⇒ Servlet ⇒ In 'Java Package', enter 'hello
'; in 'Class Name', enter 'HelloServlet
' ⇒ Next ⇒ In 'URL Mappings', select 'HelloServlet
', 'Edit' to 'Hello
' ⇒ Next ⇒ In 'Which method stubs would you like to create', check 'Inherited abstract method' and 'doGet' ⇒ Finish.(For Servlet 2.4/2.5 with Tomcat 6) The annotation @WebServlet
is new in Servlet 3.0 and is not supported in Servlet 2.4/2.5. Hence, you need to manually configure the URL for the servlet in the Web Application Deployment Descriptor 'web.xml
' under directory 'WEB-INF
', as follows:
HelloServlet
' project ⇒ 'Run As' ⇒ 'Run on Server' ⇒ Change the URL to 'http://localhost:8080/HelloServlet/sayhello
'.Right-click on the project to be exported ⇒ Export ⇒ WAR File ⇒ In 'Destination', specify the destination directory and filename (the filename shall be the web application name) ⇒ Finish.
webapps
' folder. The war file will be automatically extracted and deployed. The web application name is the war-filename.[TODO]
You can debug a webapp just like standalone application. For example, you can set breakpoints, single-step through the programs, etc.
REFERENCES & RESOURCES
The essential tools for any Java developer, including a Java IDE, a CVS client, Git client, XML Editor, Mylyn, Maven integration and WindowBuilder
Maintained by: Eclipse Mylyn Project
Bug ID | Title | Status |
516739 | Add WindowBuilder to Java package again | NEW |
513809 | [wiring] HttpComponents wiring issue | NEW |
509799 | Symantec reports a Trojan SONAR.AM.C!g24 in eclipse | NEW |
508091 | Duplicate options in Eclipse.ini | NEW |
521514 | Add 'Eclipse News' RSS feed to Java Package | NEW |
522649 | News feed plugin not installed on upgrade installs | NEW |
536469 | Use png with transparent icon in the about dialog of Java EPP (and others if applicable) | NEW |
530698 | Using weka api | NEW |
526611 | win64 version missing | NEW |
498457 | FileNotFoundException : org.eclipse.ui_3.108.0.v20160518-1929.jar | NEW |
489296 | Improve out-of-box experience for non-english locales | NEW |
386806 | New Eclipse Icon not used by Eclipse 4.2 on Windows 7 | NEW |
374170 | bugs when updating software | NEW |
364551 | setup automated tests for Java EPP package | NEW |
414381 | Failed to load the JNI shared library 'C:ogramFilesJavajre6binclientjvm.dll' | NEW |
458646 | Problème démarrage Eclipse | NEW |
355002 | EPP packages need styling | NEW |
473585 | Help system broken after updating from Luna to Mars | NEW |
487713 | FileNotFoundException: introData.xml | NEW |
382232 | Add 'EGit Import' to EPP package with EGit | ASSIGNED |
487722 | Dead link for 'Remote Help': Topic not found | REOPENED |
Bugs listed in italics indicate the bug has been moved to another project.
Bug ID | Title | Status |
382804 | Ctrl+C, Ctrl+V shortcuts don't work while editing Android XML | RESOLVED |
492163 | Add Maven to java package | RESOLVED |
383193 | Taskbar icon doesn't show Android build progress | RESOLVED |
490044 | [Welcome] Adopt Solstice theme for Java package | RESOLVED |
386686 | the Mobile package should include the Mylyn Bugzilla connector | RESOLVED |
365594 | add code recommenders to java package | RESOLVED |
358692 | Eclipse java package crash in Ubuntu 11.0.4 | RESOLVED |
356126 | fix Mylyn repository URLs in EPP packages for Indigo | RESOLVED |
356349 | update Mylyn URLs for Juno | RESOLVED |
357020 | add Mylyn Hudson/Jenkins connector to Java package | RESOLVED |
357332 | Annotations not shown on overview ruler | RESOLVED |
389113 | Unable to Launch Eclipse after download and setup: 'The Eclipse executable launcher was unable to locate its companion shared library.' | RESOLVED |
406246 | zip compression error | RESOLVED |
468598 | Mars RC1 Mac packages are damaged | RESOLVED |
535504 | Open file feature broken in Photon RC2 EPP packages | RESOLVED |
474204 | Include Buildship as part of Java package | RESOLVED |
534617 | [Photon] [java] Add Tip of the Day to the Java Package | RESOLVED |
528429 | m2e to download sources by default | RESOLVED |
194805 | add Error Log view to Java EPP distribution | RESOLVED |
432716 | Consider org.eclipse.recommenders.mylyn.rcp.feature for inclusion into Java package | RESOLVED |
483914 | bug | RESOLVED |
436206 | Re-enable Marketplace Client in Java Package | RESOLVED |
481475 | Scroll lock button being disabled | RESOLVED |
350079 | EGit should be by included in Java package | RESOLVED |
355058 | update repository locations for Juno | RESOLVED |
275767 | [Galileo M7] FileNotFoundException when updating Mylyn | RESOLVED |
275719 | [Galileo M7] packages do not have dropins folder | RESOLVED |
279203 | Add and enable Mylyn update site by default | RESOLVED |
281448 | [update] manager talking to update sites not available | RESOLVED |
549138 | Mylyn cannot be removed from Java IDE package | RESOLVED |
275558 | [Galileo M7] welcome view is not displayed on first startup | RESOLVED |
275523 | [Galileo M7] features appear twice in the about dialog | RESOLVED |
246466 | Missing/extra update sites when installing in either C:program file or C: | RESOLVED |
248976 | 'IDE for Java Developers' package is too restrictive by specifying Java 1.5 as required | RESOLVED |
275520 | [Galileo M7] package does not have any update sites | RESOLVED |
275521 | Improve branding for Galileo java package | RESOLVED |
297341 | EPP web page 'Download Milestone' link points to old builds | RESOLVED |
287566 | error on update after clean install | RESOLVED |
341705 | I tried to load the eclipse environment in Win Vista OS and got problems restoring workbench.. | RESOLVED |
343869 | Add WindowBuilder Core and Swing to the Java package | RESOLVED |
346703 | Inclusion of m2e marketplace on help menu causing confusion | RESOLVED |
348157 | intrusive 'preview?' dialog on startup, from WindowBuilder | RESOLVED |
340312 | Indigo Java package logs lots of output | RESOLVED |
334180 | package contains duplicate (and modified?) bundles | RESOLVED |
313818 | Bugzilla connector does not load on Java 1.5 due to missing java.xml.bind bundle | RESOLVED |
306817 | Cannot update from M5 to Eclipse 3.6 M6 | RESOLVED |
311613 | java IDE / m6 / linux has an EclispeCon splash screen? | RESOLVED |
507104 | Include EclEmma in Java Package | RESOLVED |
507515 | Issue encountered when updating and reinstalling ABAP Development tools on NEON version. | CLOSED |
532067 | Open Bugs | CLOSED |
530726 | Mac OS X(Cocoa)64位下载连接无效 | CLOSED |
515622 | Eclipse will not run | CLOSED |
526343 | Constantly returning error message when opening the program | CLOSED |
501518 | Exception while updating external folders | CLOSED |
521654 | Getting error while starting Apache server | CLOSED |
529170 | MacOs didnt open the program | CLOSED |
548444 | The Java GUI is too big | CLOSED |
497204 | resource in project, but error says not open | CLOSED |
547604 | Can't Install software | CLOSED |
548562 | I am not able to update because of unfound repositories. | CLOSED |
550404 | sgfghg | CLOSED |
551635 | I can't run eclipse without having a bug on it. | CLOSED |
543464 | 2018-12 Installation Error | CLOSED |
543054 | Eclipse crashing while looking at files | CLOSED |
540168 | java 11 | CLOSED |
539041 | Unable to Install | CLOSED |
541760 | Missing Java Developer links for 2018-12 M3 | CLOSED |
542080 | Problems occurred when invoking code from plug-in: 'org.eclipse.ui.views.properties.tabbed'. | CLOSED |
543011 | java.io.FileWriter, the File cannot be deleted | CLOSED |
534760 | Simple compilation fails in Eclipse Oxygen.3a | CLOSED |
457081 | Add Error Reporting to Java Package | CLOSED |
435919 | Add 'Eclipse Code Recommenders' to 'This package includes' list | CLOSED |
435449 | Add org.eclipse.recommenders.snipmatch.rcp.feature to java-package | CLOSED |
436109 | update java package maintainer information | CLOSED |
455363 | Allow users to uninstall features from a package | CLOSED |
461540 | Unarchiving error | CLOSED |
414385 | the eclipsec executable launcher was unable to locate its companion shared library | CLOSED |
384532 | The Eclipse executable launcher was unable to locate its companion shared library | CLOSED |
330226 | Inclusion of m2e | CLOSED |
304968 | LinkageError when trying to use Eclipse to run (PDE) Ant scripts | CLOSED |
349028 | fix provider name for org.eclipse.wb.discovery.* | CLOSED |
353613 | Add EGit 1.1 to java-package | CLOSED |
381216 | Zip file for Java IDE RC1 package requires a password? | CLOSED |
464220 | Bug | CLOSED |
470912 | p2 can't find epp repo for Mars release | CLOSED |
482370 | thanks | CLOSED |
482285 | Mars.1 splash screen does not show progress bar after using console | CLOSED |
484535 | An error removing AppEngine from the project | CLOSED |
494695 | Didn't update from old version | CLOSED |
495806 | Suboptimal 'Visit' link on About Eclipse Features page | CLOSED |
480756 | Switch to root level features to allow users to remove unwanted features | CLOSED |
478619 | Webapp | CLOSED |
476546 | Eclipse Mars.1 RC2 for Java Developers includes CVS cheat sheets but no CVS support | CLOSED |
476553 | Installed Code Recommenders Snipmatch and Mylyn Integration features do not *show* under Installation Details | CLOSED |
477195 | Maintainer/tester information outdated | CLOSED |
477572 | p | CLOSED |
497192 | Eclipse Mars does not open in Windows 10 Pro | CLOSED |
Bugs listed in italics indicate the bug has been moved to another project.