Skip to content

liuzhongshu/java-useful-tips

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 

Repository files navigation

java-useful-tips

Java language

JRE remote debug

add -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8074 to JRE options, suspend=y for suspend, 8074 is debug port.

external thread dump

kill -3 pid (linux) or send ctrl-break from keyboard to console (windows)

Eclipse

auto refresh resources

from Eclipse 3.7, check windows > preferences > general > workspace > Refresh using native hooks or polling

better hot swap

try jrebel (install using eclipse marketplace)

can not open java source in windowsbuilder

right click file > open with, select proper editor.

compile error for old API like BASE64Decoder

windows > preferences > Java > Compiler > Deprecated and restricted API, set Forbidden reference to Warning.

paste multi line text to java string

Preferences > Java > Editor > Typing, check "Escape text when pasting into a string literal"

Maven

set project local repository

in pom file, add:

<repositories>
 	<repository>
        <id>project.local</id>
        <name>project</name>
        <url>file:${project.basedir}/repo</url>
    </repository>
</repositories>
Dependency convergence check

in pom file, add:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <version>1.4.1</version>
    <executions>
      <execution>
        <id>enforce</id>
        <configuration>
          <rules>
            <DependencyConvergence />
          </rules>
        </configuration>
        <goals>
          <goal>enforce</goal>
        </goals>
      </execution>
    </executions>
</plugin>

Swing

how to add undo and redo to JTextArea?

http://www.java-tips.org/java-se-tips-100019/44-javax-swing-undo/1964-how-to-add-undo-and-redo-to-a-text-component.html

linux

JVM Delays Caused by Random Number Generation

add -Djava.security.egd=file:/dev/./urandom to JRE options

Don't Reinvent The Wheel

About

some useful java tips

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published