Difference between revisions of "Eclipse Tips"

From CSE231 Wiki
Jump to navigation Jump to search
(need images incomplete)
 
(28 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
Eclipse is a very powerful IDE for Java development. You can download it from [https://eclipse.org/downloads/ eclipse.org/downloads]. This page will contain tips for using Eclipse more efficiently in this class.
 
Eclipse is a very powerful IDE for Java development. You can download it from [https://eclipse.org/downloads/ eclipse.org/downloads]. This page will contain tips for using Eclipse more efficiently in this class.
  
==Refresh==
+
=Refresh=
 
Sometimes after you pull from git you will find that your project needs to be refreshed.  The following steps are a bit heavy handed, but often will get your project back up and working again.
 
Sometimes after you pull from git you will find that your project needs to be refreshed.  The following steps are a bit heavy handed, but often will get your project back up and working again.
  
Line 10: Line 10:
 
# "Project" -> "Clean..." from the menu bar.
 
# "Project" -> "Clean..." from the menu bar.
  
Note in order to invoke the function keys on some laptops you need to press the Function modifier key.
+
Note: In order to invoke the function keys on some laptops, you need to press the Function (Fn) modifier key.
  
==Maven==
+
=Maven=
Sometimes refreshing Maven isn't enough.
+
Sometimes refreshing Maven isn't enough. Refer to [[Maven_Force_Update]] to update it.
  
[[Maven_Force_Update]]
+
=Content Assist=
 +
The Content Assist feature completes partially entered code with existing code elements. Content Assist is amazing. You should use it. 
 +
===Mac===
 +
On the Mac, the Spotlight often masks content assist.  Follow [http://stefaanlippens.net/code_completion_shortcut_eclipse_osx/ this guide] to set up a new keyboard shortcut of your choosing.
 +
===Windows===
 +
On Windows, it is pretty easy.  Just type Ctrl+SPACE.
  
==Content Assist==
+
===Content Assist lambda ()->{}===
 +
set up "body" template to produce an empty lambda (see images below)
  
*[http://www.cse.wustl.edu/~cosgroved/courses/cse231/s17/tips/content_assist/ Content Assist] (autocomplete)
+
Text for the copy buffer:
**[http://www.cse.wustl.edu/~cosgroved/courses/cse231/f17/tips/import_static/ Habanero]
+
<nowiki>() -> {
**[http://www.cse.wustl.edu/~cosgroved/courses/cse231/s17/tips/lambda_template/ Lambda]
+
    ${cursor}
 +
}</nowiki>
  
==Git==
+
example usage:
 +
: type async
 +
: type ctrl+SPACE (or whatever you have mapped content assist to)
 +
: type RIGHT_ARROW
 +
: type ctrl+SPACE (or whatever you have mapped content assist to)
 +
: type ENTER
  
*[http://www.cse.wustl.edu/~cosgroved/courses/cse231/s17/tips/eclipse_git/git_menu.html Using the git menu]
+
[[File:TemplatePreferences.png]]
**[http://www.cse.wustl.edu/~cosgroved/courses/cse231/s17/tips/eclipse_git/enable_git_action_set.html Enable git action set]
 
  
==JDK Setup==
+
[[File:LambdaTemplate.png]]
  
[http://www.cse.wustl.edu/~cosgroved/courses/cse231/s17/tips/jdk/ JDK Setup]
+
===Content Assist fork, join imports===
 +
All classes are equal but some classes are more equal than others. The following will single out the FJ class to promote the static methods fork, join, and friends to be offered in content assist.
  
==JavaFX Setup==
+
[[File:V5ImportStaticPreferences.png]]
[http://www.cse.wustl.edu/~cosgroved/courses/cse231/s17/setup/JavaFX.html e(fx)clipse Setup]
 
  
==Presentation==
+
[[File:V5ImportStaticNewFavoriteType.png]]
[[Hierarchical Package Presentation]]
+
 
 +
[[File:Eclipse favorite type selection.png]]
 +
 
 +
NOTE: for the video below, replace Habanero with FJ
 +
 
 +
<youtube>YO8x-ARnd50</youtube>
 +
 
 +
=Git Action Set=
 +
Pulling, Committing, and Pushing to your git repo on bitbucket will be common operations.  Make the operations more readily available:
 +
 
 +
[[File:CustomizePerspective.png]]
 +
 
 +
[[File:ActionSetAvailability.png]]
 +
 
 +
[[File:GitActionSet.png]]
 +
 
 +
=JDK Setup=
 +
By default Eclipse is often configured to use the JRE.  Switching to the JDK is a easy way to get access to the Java source code which is great for tunneling in to see how the system is implemented.
 +
===Mac===
 +
https://manski.net/2011/12/eclipse-and-the-jdk-under-mac-os-x-lion/#manually-adding-a-jdk
 +
===Windows===
 +
http://www.gamefromscratch.com/post/2011/11/15/Telling-Eclipse-to-use-the-JDK-instead-of-JRE.aspx
 +
 
 +
=JavaFX Setup=
 +
We will use JavaFX for some visualizations this semester.  Installing the JavaFX plugin will get clean up the compiler warnings.
 +
 
 +
[https://wustl.app.box.com/file/270328288527 video walkthrough]
 +
 
 +
Install the e(fx)clipse plugin via Help -> Eclipse Marketplace:
 +
 
 +
[[File:EclipseMarketplace.png]]
 +
 
 +
[[File:MarketplaceE FX Clipse.png]]
 +
 
 +
==Linux==
 +
<nowiki>sudo apt-get install openjfx</nowiki>
 +
 
 +
or
 +
 
 +
<nowiki>sudo yum install openjfx</nowiki>
 +
 
 +
=Hierarchical Package Presentation=
 +
As the semester progresses the number of packages can get to be a bit unwieldy.  Switching to Hierarchical Package Presentation might be worth trying out.
 +
[[File:EclipsePackagePresentationHighlight.png]]

Latest revision as of 05:24, 31 December 2022

Eclipse is a very powerful IDE for Java development. You can download it from eclipse.org/downloads. This page will contain tips for using Eclipse more efficiently in this class.

Refresh

Sometimes after you pull from git you will find that your project needs to be refreshed. The following steps are a bit heavy handed, but often will get your project back up and working again.

Select your project in the package explorer:

  1. "F5" to refresh
  2. "Alt-F5" to refresh Maven
  3. "Project" -> "Clean..." from the menu bar.

Note: In order to invoke the function keys on some laptops, you need to press the Function (Fn) modifier key.

Maven

Sometimes refreshing Maven isn't enough. Refer to Maven_Force_Update to update it.

Content Assist

The Content Assist feature completes partially entered code with existing code elements. Content Assist is amazing. You should use it.

Mac

On the Mac, the Spotlight often masks content assist. Follow this guide to set up a new keyboard shortcut of your choosing.

Windows

On Windows, it is pretty easy. Just type Ctrl+SPACE.

Content Assist lambda ()->{}

set up "body" template to produce an empty lambda (see images below)

Text for the copy buffer:

() -> {
    ${cursor}
}

example usage:

type async
type ctrl+SPACE (or whatever you have mapped content assist to)
type RIGHT_ARROW
type ctrl+SPACE (or whatever you have mapped content assist to)
type ENTER

TemplatePreferences.png

LambdaTemplate.png

Content Assist fork, join imports

All classes are equal but some classes are more equal than others. The following will single out the FJ class to promote the static methods fork, join, and friends to be offered in content assist.

V5ImportStaticPreferences.png

V5ImportStaticNewFavoriteType.png

Eclipse favorite type selection.png

NOTE: for the video below, replace Habanero with FJ

Git Action Set

Pulling, Committing, and Pushing to your git repo on bitbucket will be common operations. Make the operations more readily available:

CustomizePerspective.png

ActionSetAvailability.png

GitActionSet.png

JDK Setup

By default Eclipse is often configured to use the JRE. Switching to the JDK is a easy way to get access to the Java source code which is great for tunneling in to see how the system is implemented.

Mac

https://manski.net/2011/12/eclipse-and-the-jdk-under-mac-os-x-lion/#manually-adding-a-jdk

Windows

http://www.gamefromscratch.com/post/2011/11/15/Telling-Eclipse-to-use-the-JDK-instead-of-JRE.aspx

JavaFX Setup

We will use JavaFX for some visualizations this semester. Installing the JavaFX plugin will get clean up the compiler warnings.

video walkthrough

Install the e(fx)clipse plugin via Help -> Eclipse Marketplace:

EclipseMarketplace.png

MarketplaceE FX Clipse.png

Linux

sudo apt-get install openjfx

or

sudo yum install openjfx

Hierarchical Package Presentation

As the semester progresses the number of packages can get to be a bit unwieldy. Switching to Hierarchical Package Presentation might be worth trying out. EclipsePackagePresentationHighlight.png