Search This Blog

Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

Eclipse: Disable auto escaping when pasting

 

  1. In the preferences menu deselect: Java > Editor > Typing > Escape text when pasting into a string literal
  2. Disable smart insert mode: Edit > Smart Insert Mode [Ctrl+Shift+Insert]

Good fonts for programming




ConsolasHigh and Meslo LG are good fonts for increasing the line space for Eclipse.

Install Eclipse Color Theme plugin

The update site https://eclipse-color-theme.github.com/update/ from Marketplace does NOT work.

Use the site url below:
https://eclipse-color-theme.github.io/update/

Manually add a new site: https://eclipse-color-theme.github.io/update/ and install.

Eclipse on Windows: set to use Unix newline format

  • To change the default format for new files:
    Window -> Preferences -> General -> Workspace -> New text file line delimiter
  • To convert the current file:
    File -> Convert Line Delimiters To -> Unix

Eclipse: Delete line shortcut key combo does not work

After delete .metadata directory in a eclipse workspace, my ⌘D key to delete line does not work. Found the solution below:
  • Open Preferences -> General -> Keys, then type "Delete line" in the filter text field, it should list all the matching bindings
  • Select the command "Delete line" when "Editing text", click Copy Command button to duplicate one, then set the key to "⌘⇧D", then click Apply and Close button.
  • Restart Eclipse. Now both ⌘⇧D and ⌘D should work. And you can delete the one we just added.
  • Open Preferences -> General -> Keys, select the command we just added, and click Restore Command to remove it.

JavaFX Development: Install e(fx)clipse plugin for Eclipse

Develop JavaFX application using eclipse, you may experiencing this error:
Access restriction: The type Pane is not accessible due to restriction on required library C:\Program Files\Java\jre8_0\lib\ext\jfxrt.jar


There are a few ways to resolve this issue. The easiest solution is to install e(fx)clipse plugin.
  1. Find the latest release, by opening web page: https://download.eclipse.org/efxclipse/updates-released
  2. In Eclipse (Mac OS), Help => Install New Software... => Add site: https://download.eclipse.org/efxclipse/updates-released/3.5.0/site
  3. Check 'e(fx)clipse -install' and click Next button to install.

Disable smart dashs or smart quotes on Mac

# Disable just smart dashes
defaults write -g NSAutomaticDashSubstitutionEnabled 0

# Disable just smart quotes
defaults write -g NSAutomaticQuoteSubstitutionEnabled 0

# To re-enable, set either back to 1.

Eclipse Debug Arguments: double dashes are replaced by single long dash automatically. How to disable smart dashes substitution?

On Eclipse Oxygen, when input double dash -- into "Arguments" of "Debug Configurations...", It substitutes double dash -- with single long dash —
It is really annoying. You cannot even input the correct arguments. The only way to make it work is to disable "Smart Dashes" See below:



  • Right click the Arguments area to open the context menu
  • Select "Substitutions" then uncheck "Smart Dashes"
  • Now you should be able to input double dashes



Enable Mac OS X Integration library (com.apple.eawt.*) in Eclipse Java 8 Project

  1. Right click the project, select 'Build Path' then 'Configure Build Path...'
  2. Activate 'Libraries' tab, then open 'JRE System Library', then select Access Rules...
  3. Click 'Edit...' button, then click 'Add' button and type the rules:
    • Resolution: 'Accessible'
    • Rule Pattern: 'com/apple/eawt/**'

Eclipse: count the number of lines

  • Search -> File...
  • Check "Regular Expression" and enter "Containing text": ^.*$
  • Enter "File name patterns": *.java
  • Click "Search" button
  • In the result "Search" tab, the number of matches is the number of lines (exclude blank lines)

Eclipse 4.4 Luna on Mac OS 10.9.5: Eclipse.app is not supported on this type of mac

I have recently installed Mac OS 10.9.5 update. After update, I found Eclipse.app failed to start, it pops up a window with message: "It is not supported on this type of Mac."

The solution is:

  1. Find your java home:
    /usr/libexec/java_home -V
    , you can see the java home like below:
    Matching Java Virtual Machines (1):
        1.8.0_20, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
    
    /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
  2. Edit file: /Applications/eclipse/Eclipse.app/Contents/Info.plist, and insert the follow line:
    <string>-vm</string><string>/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/java</string>
    to the proper location.
  3. Now you can try to click the Eclipse.app icon, if it pops up another error message: "Eclipse is damaged and can’t be opened. You should move it to Trash.", you will need to run the following command to fix:
    xattr -d com.apple.quarantine /Applications/eclipse/Eclipse.app/
  4. Note: you can run the following command to check directory attributes:
    xattr /Applications/eclipse/Eclipse.app/

see also

Eclipse for Windows: Could not open/create prefs root node Software\JavaSoft\Prefs

When compiling a project cloned from git repository, got the following warning:
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.

Solution:

  • Run regedit
  • Locate key HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs
  • Right click the icon then select Permissions...
  • Give full control to users

Eclipse: remove Java comments

  • remove all /** ... ... */ comments:


    Regular Expression: /\*(?s:(?!\*/).)*\*/
  • remove all /* ... ... */ comments:


    Regular Expression: /\*\*(?s:(?!\*/).)*\*/

see also

Upgrade existing Eclipse standard/classic to J2EE

go to the Help menu, choose Install New Software, and while Working With All Available Sites, choose the features you want from the Web, XML, Java EE and OSGi Enterprise Development category. If unsure, pick both the Eclipse Java EE Developer Tools and JST Server Adapters Extensions and proceed, allowing it to select dependencies for you.

For those certain that they only want to install selected parts of WTP, the Eclipse XML Editors and Tools selection is exactly as named while the Eclipse Web Developer Tools builds on that with HTML, CSS, and JavaScript tools, and supports deployable "static" web projects. The Eclipse Java Web Developer Tools adds support for JSP files (but not Java Servlets), and complete support for "dynamic" web projects requires the full Eclipse Java EE Developer Tools Feature.

See also

eclipse annotation: @SuppressWarnings

To suppress single type of warnings:
@SuppressWarnings("unchecked")

To suppress multiple types of warnings:
@SuppressWarnings({"unused", "unchecked"})

Eclipse on Mac OS X: key combo for Java refactoring does not work after installing pydev

PyDev bind Command+Option+R to 'Set Next Statement' which is conflicting with Java refactor shortcut key combo.
To restore the Java refactor key combo (and deactivate the key combo for PyDev):
  1. Eclipse -> Preferences... -> General -&gt Keys
  2. Sort by Binding by clicking the Binding column header
  3. Select the row: Command: Set Next Statement and Category: Python - Run
  4. Click "Unbind Command" button
  5. Select the row: Command: Rename - Refactoring and Category: Refactor - Java
  6. Click to select Binding field
  7. Type Command+Option+R
  8. Click Apply button then OK button to save.

see also

Ant in Eclipse: javac1.8 class not found

If you are running ANT in Eclipse using Java 8. The error
Class not found: javac1.8
could happen. Because Apache Ant versions less than 1.9.0 - are not compatible with Java 8. The solution could be
  • Option 1: Install Java 7 and set JAVA_HOME for eclipse to use Java 7.
  • Option 2: Add compiler or build.compiler attribute to the javac task in your ant build.xml:
    <target name="compile">
        <javac srcdir="src" destdir="build/classes" source="1.6" target="1.6" compiler="javac1.7" >
            <classpath>
                <fileset dir="lib">
                    <include name="*.jar" />
                </fileset>
            </classpath>
        </javac>
    </target>

see also

Eclipse on Mac OS X: set the Java runtime used by eclipse by editting eclipse.ini

Edit eclipse.ini:
vi /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini
insert the following lines before -vmargs:
-vm
/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin/java
-vmargs

see also

m2eclipse: use java 1.6 instead of 1.5

m2eclipse uses java 1.5 by default. To make your project use java 1.6. you need to edit your pom.xml file:
<project>

        ... ...

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

then right click your project in eclipse, select Maven -> Update Maven Project.