pages tagged tool http://meng6net.localhost/tag/tool/ <p><small>Copyright © 2005-2020 by <code>Meng Lu &lt;lumeng3@gmail.com&gt;</code></small></p> Meng Lu's home page ikiwiki Mon, 26 Oct 2020 18:12:13 +0000 Installing CheckStyle plugin for Eclipse http://meng6net.localhost/blog/Installing_CheckStyle_plugin_for_Eclipse/ http://meng6net.localhost/blog/Installing_CheckStyle_plugin_for_Eclipse/ eclipse java syntax tool Tue, 16 May 2017 23:59:39 +0000 2018-10-13T03:27:57Z <p>I recently discovered a tool for checking Java code formatting and other coding style related issues -- <a href= "http://checkstyle.sourceforge.net/">CheckStyle</a>. It features <a href="http://checkstyle.sourceforge.net/availablechecks.html">a list of style checks</a> such as</p> <blockquote> <p>...<br /> * Restricts nested boolean operators (&amp;&amp;, ||, &amp;, | and ^) to a specified depth (default = 3).<br /> * Checks for empty blocks.<br /> * Checks for long source files.<br /> ...</p> </blockquote> <p>There's also an Eclipse plugin for it: https://checkstyle.org/eclipse-cs/#!/. The Eclispe update URL is http://eclipse-cs.sf.net/update/. As of at least Eclipse 4.8.0 (Aug., 2018), this update URL no longer works.</p> <p>There is a caveat at the time I install it:</p> <p>the plugin's homepage http://eclipse-cs.sourceforge.net/ gives http://sevntu-checkstyle.github.com/sevntu.checkstyle/update-site/ as the installation URL, but it does not work. However on http://eclipse-cs.sourceforge.net/downloads.html a different installation URL http://eclipse-cs.sf.net/update/ is given, which turns out to work correctly. It seems someone has not updated the Web pages consistently. And it has certainly confused some: http://stackoverflow.com/questions/11865025/error-while-installing-check-style-plugin-for-eclipse.</p> /blog/Installing_CheckStyle_plugin_for_Eclipse/#comments Installing and configuring Thunderbird http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_Thunderbird/ http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_Thunderbird/ computing configuration documentation email installation note software thunderbird tool Tue, 16 May 2017 23:59:39 +0000 2017-05-16T23:59:39Z <ul> <li> <p>Install Thunderbird.</p> </li> <li> <p>Set up accounts</p> <ul> <li>Add email account with IMP/POP3 server and SMTP server.</li> <li>Add sigunature, reply-to address, organization.</li> </ul> </li> <li> <p>Account settings (Edit &gt; Settings (Linux), Tools &gt; Account Settings (macOS))</p> <ul> <li>Server Settings: set emails to be checked sufficiently frequently, e.g. every 2 minute for work-related accounts.</li> <li>Copies &amp; Folders: set sent emails to be bcc-ed to oneself for the purpose of verifying successful sending.</li> <li>Composition &amp; Addressing: choose "place my signature below my reply", Add LDAP address server.</li> <li>Junk Settings: disable "adaptive junk mail controls for this account";</li> </ul> </li> <li> <p>Preferences (Edit &gt; Preferences (Linux), Thunderbird &gt; Preferences (macOS)):</p> <ul> <li>Display: <ul> <li>Add tags: 'ToDo', 'ToLearn', 'ToDelete'.</li> <li>Formatting: <ul> <li>Proportional: serif;</li> <li>Size: 24;</li> <li>Use UTF-8 as default character encodings for incoming and outgoing emails;</li> <li>Check "When possible, use the default character encoding in replies";</li> </ul> </li> </ul> </li> <li>Advanced: <ul> <li>Reading &amp; Display: Automatically mark messages as read after reading for 2 seconds.</li> </ul> </li> </ul> </li> <li> <p>Set up message filters.</p> <ul> <li>Ideally recover them from a backup using the add-on "Thunderbird Message Filter Import/Export Enhanced", or</li> <li>Re-create them manually following a previously made note of what they were and how they were set up.</li> </ul> </li> <li> <p>Set up saved search folders. Ideally recover them from a backup or a note of what they were and how they were set up.</p> </li> <li> <p>Install add-ons</p> <ul> <li>Enigmail</li> <li>Expression Search/Google Mail UI</li> <li>Extra Folder Columns</li> <li>Lightning, connect to Zimbra Calendar</li> <li>Markdown Here</li> <li>Thunderbird Message Filter Import/Export Enhanced</li> <li>TT DeepDark theme</li> </ul> </li> <li> <p>Set up calendars, the Today Pane</p> </li> <li> <p>Set up contacts, contact groups.</p> </li> <li> <p>Set up address book. Restore the address book 'Personal Address Book' data by importing previously backed up address book data, using the menu item Window &gt; Address Book (macOS) Tools &gt; Import</p> <blockquote> <p>... (Linux).</p> </blockquote> </li> <li> <p>Set up personal dictionary.</p> <ul> <li>Navigate to the profile directory (<code>~/.thunderbird/XXX/</code> for Linux and <code>~/Library/Thunderbird/Profiles/XXX/</code> for macOS);</li> <li>Create a symbolic link from a back-up personal dictionary data file <code>persdict.dat</code> to this path. C.f. http://kb.mozillazine.org/Dictionaries#Personal_dictionary</li> </ul> </li> <li> <p>Profile directory and data</p> </li> </ul> <p>C.f. http://kb.mozillazine.org/Profile_folder<em>-</em>Thunderbird</p> <p>All the emails data, message filters, and some other configuration data are saved in the Thunderbird profile directory (<code>~/.thunderbird</code> for Linux and <code>~/Library/Thunderbird/Profiles/</code>).</p> <p>Sometimes data can be recovered from using the profile directory and data from some other computer.</p> <ul> <li>Open the frequently viewed folders as their own "sticky" tabs.</li> </ul> Installing and configuring Eclipse http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_eclipse/ http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_eclipse/ computing configuration documentation eclipse installation note plugin software tool Tue, 16 May 2017 23:59:39 +0000 2020-10-26T18:12:13Z <p>Last verification: 2020-10-26, macOS version 10.14.6, Eclipse version 2020-09 (4.17.0).</p> <h2>eclipse.ini</h2> <h3>Memory size</h3> <p>On macOS, the configuration file</p> <pre><code> ../Eclipse.app/Contents/MacOS/eclipse.ini </code></pre> <p>or for Eclipse 4.5 and later:</p> <pre><code> ../Eclipse.app/Contents/Eclipse/eclipse.ini </code></pre> <p>has</p> <pre><code>-startup ../../../plugins/org.eclipse.equinox.launcher_1.0.101.R34x_v20080819.jar --launcher.library ../../../plugins/org.eclipse.equinox.launcher.carbon.macosx_1.0.101.R34x_v20080731 -showsplash org.eclipse.platform -vmargs -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Xms1024m -Xmx1536m -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+UseParallelGC -Dorg.eclipse.swt.internal.carbon.smallFonts </code></pre> <ul> <li><code>Xms</code> and <code>Xmx</code> are the starting and maximum heap size for JVM running Eclipse, respectively. Heap stores objects, so anything that create large number of objects will require large value for <code>Xmx</code></li> <li><code>PermSize</code> and <code>MaxPermSize</code> are for memory storing classes (data structures, not object instances) so they normally don't need to be large[<sup id="fnref:1"><a href= "http://meng6net.localhost/tag/tool/#fn:1" rel="footnote">1</a></sup>].</li> <li><code>-Xss2m</code> sets the Java stack size to 2MB; If it requires very deep level of recursion and can have large inputs, a stack size too small may cause <code>java.lang.StackOverflowError</code></li> <li><code>-XX:+UseParallelGC</code> enables the <em>parallel garbage collector</em>[<sup id="fnref:2"><a href="http://meng6net.localhost/tag/tool/#fn:2" rel= "footnote">2</a></sup>].</li> </ul> <h3><code>-Dorg.eclipse.swt.internal.carbon.smallFonts</code></h3> <p>On high-resolution displays, removing</p> <pre><code>-Dorg.eclipse.swt.internal.carbon.smallFonts </code></pre> <p>is said to make the font size larger for some GUI elements. But I couldn't notice any difference.</p> <p>References:</p> <ul> <li> http://apple.stackexchange.com/questions/24621/how-do-increase-font-size-of-eclipse-globally</li> </ul> <h2>Preferences</h2> <p>Note preferences are workspace specific and you can export, save, and import preferences metadata using menu File ⟶ Export ⟶ Preferences [<sup id="fnref:3"><a href="http://meng6net.localhost/tag/tool/#fn:3" rel= "footnote">3</a></sup>].</p> <ul> <li> <p>Preferences ⟶ General ⟶ Compare/Patch ⟶ enable "Ignore white space"</p> </li> <li> <p>Preferences ⟶ General ⟶ Keys ⟶ Scheme:Emacs</p> </li> <li> <p>Preferences ⟶ General ⟶ Network Connections</p> <ul> <li>⟶ SSH2: add private keys</li> </ul> </li> <li> <p>Preferences ⟶ General ⟶ Editors</p> <ul> <li>Check "Allow in-place system editors".</li> <li>Size of recently opened files list: 20 (the maximum)</li> <li>⟶ Text Editors: <ul> <li>Uncheck "Enable spell checking" to help speeding up text editor.</li> <li>Check "Show print margin".</li> <li>Check "Insert spaces for tabs".</li> <li>Check "Show whitespace characters".</li> </ul> </li> <li>⟶ AnyEdit Tools: <ul> <li>Convert: Tab width/number of spaces for tab: 4</li> </ul> </li> </ul> </li> <li> <p>Preferences ⟶ General ⟶ Appearance</p> <ul> <li>⟶ Theme: Dark</li> <li> <p>If the "Darkest Dark Theme with DevStyle" plug-in is installed</p> <ul> <li>⟶ Theme: DevStyle Theme</li> <li>⟶ DevStyle ⟶ Color Themes <ul> <li>Workbench theme: Dark Gray (Darkest Dark)</li> <li>Icon colors: Pastels</li> <li>Editor theme: Solarized Dark</li> <li>check "Theme background"</li> <li>check "Enable breadcrumb"</li> </ul> </li> </ul> </li> <li> <p>⟶ Colors and Fonts ⟶</p> </li> <li> <p>⟶ Basic ⟶ Text Font: Source Code Pro 18</p> <ul> <li>⟶ CVS <ul> <li>Outgoing Change (Background): dark green</li> <li>Outgoing Change (Foreground): white</li> <li>Ignored Resource (Background): dark gray</li> <li>Ignored Resource (Foreground): light gray</li> </ul> </li> <li>⟶ Git <ul> <li>Uncommitted Change (Background): dark green</li> <li>Uncommitted Change (Foreground): white</li> <li>Ignored Resource (Background): dark gray</li> <li>Ignored Resource (Foreground): light gray</li> </ul> </li> </ul> </li> </ul> </li> <li> <p>Preferences ⟶ Team ⟶ CVS</p> <ul> <li>⟶ Console: Check "Show CVS console automatically when command is run"</li> <li>⟶ Ext Connection: let CVS modules use ext connection method to use Eclipse's extssh connection method. Reference: Eclipse (version 4) documentation <a href= "http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Freference%2Fref-19cvs-ext.htm"> Workbench User Guide &gt; Reference &gt; Preferences: CVS Ext Connection Method</a> <ul> <li>Check "Use another connection method type to connect";</li> <li>For Connection type, select 'extssh'.</li> </ul> </li> </ul> </li> <li> <p>Preferences ⟶ Java ⟶ Editor</p> <ul> <li>⟶ Content Assistant: Change "Auto Activation Delay" to 500 ms.</li> </ul> </li> </ul> <h3>Preferences ⟶ Wolfram (with Wolfram Workbench plugin)</h3> <ul> <li>⟶ Editor <ul> <li>⟶ Advanced: Editor update delay (ms). I use 1500 ms.</li> <li>⟶ Indenting: Indent with spaces</li> </ul> </li> <li>⟶ Wolfram Cloud <ul> <li>User name: (email address)</li> </ul> </li> </ul> <h2>Plug-ins</h2> <p>(If not specifically mentioned, in reasonably modern version of Eclipse, install plug-ins using the menu Help &gt; Eclipse Marketplace.)</p> <h3>UI</h3> <ul> <li><a href= "https://www.genuitec.com/products/devstyle/">DevStyle</a> <ul> <li>As of Eclipse 4.7, one can install it from Help &gt; Eclipse Marketplace. I use the "Darkest Dark" color theme by setting Preferences ⟶ General ⟶ Appearance ⟶ Theme: DevStyle Theme (Darkest Dark).</li> <li>4.4+: Use Preferences ⟶ General ⟶ Appearance ⟶ Theme: Dark</li> <li>Pre-4.4: <ul> <li><a href= "http://marketplace.eclipse.org/content/eclipse-4-chrome-theme">Jeeeyul's Eclipse Themes</a>, customize UI elements such as window color.</li> <li><a href= "http://marketplace.eclipse.org/content/eclipse-color-theme">Eclipse Color Theme</a> Customize editor styles such as font, background color, etc.</li> </ul> </li> </ul> </li> </ul> <h3>Java</h3> <ul> <li> <p><a href="http://checkstyle.sourceforge.net/">CheckStyle</a></p> <ul> <li>As of Eclipse 2020-09, one can install it from Help &gt; Eclipse Marketplace. The name of the plug-in as of Eclipse 2020-09 is "Checkstyle Plug-in 8.35.0".</li> <li>As of Eclipse 4.6, one can install it from Help &gt; Eclipse Marketplace. The name of the plug-in as of Eclipse 4.8.0 (Aug., 2018) is "Checkstyle Plug-in 8.12.0".</li> <li>Eclipse plug-in site: http://eclipse-cs.sourceforge.net/</li> <li>Plug-in repository URL: http://eclipse-cs.sf.net/update/</li> <li>Available checks: http://checkstyle.sourceforge.net/availablechecks.html</li> <li><a href= "http://algs4.cs.princeton.edu/linux/checkstyle.xml">Robert Sedgewick's check-style configuration file used for his algorithms course</a>.</li> <li>I usually set it to use "Google Checks" in Window &gt; Preferences &gt; CheckStyle &gt; Global Checks Configuration.</li> </ul> </li> <li> <p><a href= "http://findbugs.sourceforge.net/">FindBugs/SpotBugs</a></p> <ul> <li>As of Eclipse version 2018-09 (4.9.0) and Sept. 2018, according to https://github.com/spotbugs/spotbugs, FindBugs has been succeeded by SpotBugs, and install the SpotBugs plug-in from Help &gt; EclipseMarketplace.</li> <li>As of Eclipse 4.4, one can install it from Help &gt; Eclipse Marketplace.</li> <li>Plug-in repository URL: http://findbugs.cs.umd.edu/eclipse or http://findbugs.cs.umd.edu/eclipse-candidate if the former does not work.</li> <li><a href= "http://algs4.cs.princeton.edu/linux/findbugs.xml">Robert Sedgewick's FindBugs configuration file used for his algorithms course</a>.</li> </ul> </li> <li> <p><a href= "https://marketplace.eclipse.org/content/eclipse-code-recommenders"> Eclipse Code Recommenders</a></p> <ul> <li>As of 2020-10 and Eclipse 2020-09, it reports "repository not available" error when attempting to install it.</li> <li>Install it from Help &gt; Eclipse Marketplace.</li> </ul> </li> <li> <p><a href="http://www.objectaid.com/">ObjectAid UML Explorer</a></p> <ul> <li>Plug-in repository URL: http://www.objectaid.com/update/current</li> </ul> </li> </ul> <h3>Uqbar Tomcat XT Eclipse Plug-in</h3> <p>For launch and administer Tomcat's contexts.</p> <ul> <li>As of Eclipse 4.4, one can install it from Help &gt; Eclipse Marketplace.</li> </ul> <h3>Scala</h3> <ul> <li><a href="http://scala-ide.org/">Scala IDE</a>.</li> <li>As of Eclipse 4.4, one can install it from Help &gt; Eclipse Marketplace.</li> <li>Plug-in repository URL: http://scala-ide.org/download/current.html.</li> </ul> <h3>Mathematica</h3> <ul> <li>Wolfram Workbench <ul> <li>As of 2018-10 and Eclipse version 2018-09 (4.9.0), install it manually following the instruction at https://web.archive.org/web/20180108074322/http://support.wolfram.com/kb/27221.</li> <li>As of 2017-10, install it from Help &gt; Elcipse Marketplace: http://marketplace.eclipse.org/content/wolfram-workbench-2).</li> </ul> </li> </ul> <h3>Version control</h3> <ul> <li> <p>CVS Integration</p> <ul> <li>As of at least Eclipse version 2018-09 (4.9.0), to install CVS client, <ol> <li>Help &gt; Install New Software...</li> <li>Set 'Work with: --All Available Sites--'.</li> <li>Type filter text 'CVS'.</li> <li>Install 'Eclipse CVS Client'.</li> </ol> </li> <li>Since Eclipse 4.5, it is no longer included in Eclipse by default. One can install it by going to the menu Help &gt; Eclipse Marketplace and searching by keyword "CVS Integration"</li> </ul> </li> <li> <p><a href="http://eclipse.org/egit/">EGit</a></p> <ul> <li>Since Eclipse 4.4, it is included in Eclipse as the built-in Git support.</li> </ul> </li> </ul> <p>I don't use Mercurial and SVN any more as of Eclipse 4:</p> <ul> <li><a href= "http://www.javaforge.com/project/HGE">MercurialEclipse</a></li> <li><a href="http://subclipse.tigris.org/">Subclipse</a></li> </ul> <h3>Editing</h3> <ul> <li><a href="http://andrei.gmxhome.de/anyedit/">AnyEdit</a> <ul> <li>As of Eclipse 4.4, one can install it from Help &gt; Eclispe Marketplace.</li> <li>Plug-in repository URL: http://andrei.gmxhome.de/eclipse/.</li> </ul> </li> </ul> <h3>Programming languages</h3> <ul> <li><a href="http://eclipsejsonedit.sourceforge.net/">JSON editor</a> <ul> <li>As of at least Eclipse 4.7.0 and 2017-8, one can install it from Help &gt; Eclispe Marketplace.</li> </ul> </li> <li><a href="http://www.eclipse.org/papyrus/">Papyrus</a>: UML modeling support</li> </ul> <h3>Misc</h3> <ul> <li><a href="http://eclipse.org/mylyn">Eclipse Mylyn</a> <ul> <li>Plug-in repository URL: http://download.eclipse.org/mylyn/releases/latest.</li> <li><a href="https://wiki.eclipse.org/Mylyn/FAQ">FAQ</a>.</li> </ul> </li> <li><a href="http://eclipse.org/gef">Eclipse Graphical Editing Framework</a> <ul> <li>Plug-in repository URL: http://download.eclipse.org/tools/gef/updates/releases</li> </ul> </li> <li><a href= "https://marketplace.eclipse.org/content/os-x-eclipse-launcher">OS X Eclipse Launcher</a> <ul> <li>As of at least Eclipse version 2019-06 (4.12.0) and 2019-6, one can install it from Help &gt; Eclispe Marketplace.</li> </ul> </li> <li><a href= "https://marketplace.eclipse.org/content/workspace-badge-plug-mac-os-x"> Workspace Badge Plug-in for macOS</a>. <ul> <li>As of at least Eclipse version 2019-06 (4.12.0) and 2019-6, this is superseded by the <a href= "https://marketplace.eclipse.org/content/os-x-eclipse-launcher">OS X Eclipse Launcher</a> plug-in.</li> </ul> </li> </ul> <h2>References</h2> <ul> <li><a href= "http://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse%3F"> Eclipse Wiki: FAQ How do I increase the heap size available to Eclipse?</a></li> </ul> <div class="footnotes"> <hr /> <ol> <li id="fn:1"><a href= "https://stackoverflow.com/questions/12114174/what-does-xxmaxpermsize-do/12114284#12114284"> https://stackoverflow.com/questions/12114174/what-does-xxmaxpermsize-do/12114284#12114284</a><a href="http://meng6net.localhost/tag/tool/#fnref:1" rev="footnote">↩</a></li> <li id="fn:2"><a href= "https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/parallel.html"> https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/parallel.html</a>, <a href= "https://web.archive.org/web/20200211194652/https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/parallel.html"> https://web.archive.org/web/20200211194652/https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/parallel.html</a><a href="http://meng6net.localhost/tag/tool/#fnref:2" rev="footnote">↩</a></li> <li id="fn:3"><a href= "http://stackoverflow.com/questions/4214526/how-to-save-eclipse-settings-fonts-formatting-etc"> http://stackoverflow.com/questions/4214526/how-to-save-eclipse-settings-fonts-formatting-etc</a><a href="http://meng6net.localhost/tag/tool/#fnref:3" rev="footnote">↩</a></li> </ol> </div> Installing and configuring Gradle http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_gradle/ http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_gradle/ computing configuration documentation gradle installation java note software tool tutorial Tue, 16 May 2017 23:59:39 +0000 2017-05-16T23:59:39Z <p><a href="http://spring.io/guides/gs/gradle/">Spring Framework guides ''Building Java Projects with Gradle'': http://spring.io/guides/gs/gradle/</a> is a good reference for this topic.</p> <h2>Install Gradle</h2> <p>On macOS, install with Homebrew</p> <pre><code>$ brew install gradle ==&gt; Downloading https://services.gradle.org/distributions/gradle-1.12-bin.zip ######################################################################## 100.0% /usr/local/Cellar/gradle/1.12: 155 files, 44M, built in 106 seconds$ brew install gradle ==&gt; Downloading https://services.gradle.org/distributions/gradle-1.12-bin.zip ######################################################################## 100.0% /usr/local/Cellar/gradle/1.12: 155 files, 44M, built in 106 seconds </code></pre> <p>Verify it's installed successfully:</p> <pre><code>$ which gradle /usr/local/bin/gradle $ gradle -version ------------------------------------------------------------ Gradle 2.0 ------------------------------------------------------------ Build time: 2014-07-01 07:45:34 UTC Build number: none Revision: b6ead6fa452dfdadec484059191eb641d817226c Groovy: 2.3.3 Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013 JVM: 1.6.0_65 (Apple Inc. 20.65-b04-462) OS: macOS 10.9.4 x86_64 </code></pre> <h2>Create Gradle-managed Java projects in IntelliJ IDEA</h2> <p>Really, there are just two easy steps:</p> <p>Create New Project, and then</p> <p><a href= "http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_gradle/image/intellij_idea_create_java_project_with_gradle_1.png"> <img src= "http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_gradle/image/intellij_idea_create_java_project_with_gradle_1.png" width="900" height="392.037470725995" class="img" /></a> ☝ step 1: pick Gradle, check <a href= "http://www.jetbrains.com/idea/webhelp/importing-project-from-gradle-model.html"> "Use auto-import"</a>, check "Create directories for empty content roots automaticaly", pick JDK version,</p> <p><a href= "http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_gradle/image/intellij_idea_create_java_project_with_gradle_2.png"> <img src= "http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_gradle/image/intellij_idea_create_java_project_with_gradle_2.png" width="900" height="624.324324324324" class="img" /></a> ☝ step 2: specify settings of the project.</p> <p>Alternatively, one can create a Java project using Gradle from UNIX command line and optionally import it later into an IDE such as IntelliJ IDEA or Eclipse.</p> <h2>Create a Java project using Gradle</h2> <p>Create a project using Gradle:</p> <pre><code>$ mkdir gradlehelloworld $ cd gradlehelloworld $ gradle init --type java-library :wrapper :init BUILD SUCCESSFUL Total time: 4.974 secs </code></pre> <p>Alternatively, use <code>gradle buildInit --type java-library</code> to create it.</p> <p>It automatically creates the project structure including directories and template files:</p> <pre><code>$ tree . ├── build.gradle ├── gradle │ └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src ├── main │ └── java │ └── Library.java └── test └── java └── LibraryTest.java 7 directories, 8 files </code></pre> <h2>Make a minimal and slightly non-trivial Java program including tests and Gradle build script</h2> <p>I'll rename <code>Library</code> to <code>Main</code> in the file names and source code, and create a toy Java project with a test:</p> <p><code>Main.java</code>:</p> <pre><code>package gradlehelloworld; import com.google.common.base.Strings; public class Main { public static void main(String[] args) { System.out.println(getGreeting("World")); System.out.println("My name is " + System.getProperty("gradlehelloworld.name")); } static String getGreeting(String name) { return Strings.repeat(String.format("Hello %s!\n", name), 2); } } </code></pre> <p><code>MainTest.java</code>:</p> <pre><code>package gradlehelloworld; import static org.junit.Assert.*; import static org.hamcrest.CoreMatchers.*; import org.junit.Test; public class MainTest { @Test public void getGreeting() { Main classUnderTest = new Main(); assertThat(classUnderTest.getGreeting("World"), equalTo("Hello World!\nHello World!\n")); } } </code></pre> <p>Edit the Gradle build script <code>gradlehelloworld/build.gradle</code>:</p> <pre><code>// Apply the java plugin to add support for Java apply plugin: 'java' apply plugin: 'application' sourceCompatibility = '1.6' mainClassName = 'gradlehelloworld.Main' // In this section you declare where to find the dependencies of your project repositories { // Use 'maven central' for resolving your dependencies. // You can declare any Maven/Ivy/file repository here. mavenCentral() } // In this section you declare the dependencies for your production and test code dependencies { // The production code uses the SLF4J logging API at compile time // compile 'org.slf4j:slf4j-api:1.7.5' compile 'com.google.guava:guava:17.0' // Declare the dependency for your favourite test framework you want to use in your tests. testCompile 'junit:junit:4.11' } run { systemProperty 'gradlehelloworld.name', 'FooBar' } </code></pre> <p>I added these code in <a href= "https://github.com/lumeng/repogit-java-memory-use-experiment">a repository on GitHub</a>. The actual code in the repository is slightly different from the above as I have developed new content and played with variations in it.</p> <h2>Run/build Java project using Gradle</h2> <p>Let Gradle download dependency Guava from Maven Central repository, compile <code>Main.java</code> program, set <code>gradlehelloworld.name</code> to <code>"FooBar"</code>, and run it with Guava on the Java classpath:</p> <pre><code>$ gradle run :compileJava Download http://repo1.maven.org/maven2/com/google/guava/guava/17.0/guava-17.0.pom Download http://repo1.maven.org/maven2/com/google/guava/guava-parent/17.0/guava-parent-17.0.pom Download http://repo1.maven.org/maven2/com/google/guava/guava/17.0/guava-17.0.jar :compileJava FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileJava'. &gt; invalid source release: 1.8 * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 14.309 secs </code></pre> <p>If I change</p> <pre><code>sourceCompatibility = '1.8' </code></pre> <p>to</p> <pre><code>sourceCompatibility = '1.6' </code></pre> <p>it then works:</p> <pre><code>$ gradle run :compileJava :processResources UP-TO-DATE :classes :run Hello World! Hello World! My name is FooBar BUILD SUCCESSFUL Total time: 6.13 secs </code></pre> <p>To use <code>sourceCompatibility = '1.8'</code>, it might need to set <code>JAVA_HOME</code> environment variable to value of <code>/usr/libexec/java_home -v 1.8</code>.</p> <p>Do a full build including running tests:</p> <pre><code>$ gradle build :compileJava :processResources UP-TO-DATE :classes :jar UP-TO-DATE :assemble UP-TO-DATE :compileTestJava UP-TO-DATE :processTestResources UP-TO-DATE :testClasses UP-TO-DATE :test UP-TO-DATE :check UP-TO-DATE :build UP-TO-DATE BUILD SUCCESSFUL Total time: 6.489 secs </code></pre> <p>Check the test report at</p> <pre><code>./build/reports/tests/index.html </code></pre> <p>Remarks:</p> <ul> <li>Note it uses <code>assertThat</code> instead of <code>assertTrue</code></li> </ul> <p><code>assertTrue(classUnderTest.getGreeting("World"), equalTo("Hello World!\nHello World!\n"));</code></p> <p><code>assertThat(classUnderTest.getGreeting("World"), equalTo("Hello World!\nHello World!\n"));</code></p> <ul> <li>Note the use of <code>import static</code> (c.f. <a href= "http://stackoverflow.com/questions/6772647/junit-method-not-found"> a related stackoverflow.com thread</a>.)</li> </ul> <p>At this point your project structure looks like:</p> <pre><code>$ tree . ├── build │ ├── classes │ │ ├── main │ │ │ ├── gradle_hello_world │ │ │ │ └── Main.class │ │ │ └── gradlehelloworld │ │ │ └── Main.class │ │ └── test │ │ └── gradlehelloworld │ │ └── MainTest.class │ ├── dependency-cache │ ├── libs │ │ ├── gradle_hello_world.jar │ │ └── gradlehelloworld.jar │ ├── reports │ │ └── tests │ │ ├── classes │ │ │ ├── css │ │ │ │ ├── base-style.css │ │ │ │ └── style.css │ │ │ ├── gradlehelloworld.MainTest.html │ │ │ ├── htc │ │ │ │ └── css3-pie-1.0beta3.htc │ │ │ └── js │ │ │ └── report.js │ │ ├── css │ │ │ ├── base-style.css │ │ │ └── style.css │ │ ├── htc │ │ │ └── css3-pie-1.0beta3.htc │ │ ├── index.html │ │ ├── js │ │ │ └── report.js │ │ └── packages │ │ ├── css │ │ │ ├── base-style.css │ │ │ └── style.css │ │ ├── gradlehelloworld.html │ │ ├── htc │ │ │ └── css3-pie-1.0beta3.htc │ │ └── js │ │ └── report.js │ ├── test-results │ │ ├── TEST-gradlehelloworld.MainTest.xml │ │ └── binary │ │ └── test │ │ ├── output.bin │ │ ├── output.bin.idx │ │ └── results.bin │ └── tmp │ └── jar │ └── MANIFEST.MF ├── build.gradle ├── build.gradle~ ├── gradle │ └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── settings.gradle~ └── src ├── main │ └── java │ ├── Main.java │ └── Main.java~ └── test └── java ├── MainTest.java └── MainTest.java~ 34 directories, 37 files </code></pre> <p>The <code>build/</code> sub-directory contains the build, Java doc pages, JUnit test reports, etc.</p> <h2>Import the project into IntelliJ IDEA</h2> <p><a href="http://www.jetbrains.com/idea/">IntelliJ IDEA</a> is a popular IDE for Java. One can import the Gradle project created above to the IDE.</p> <ol> <li>Import the Gradle project into IntelliJ IDEA, by following the documentation instruction <a href= "http://www.jetbrains.com/idea/webhelp/importing-project-from-gradle-model.html"> "Importing Project from Gradle Model"</a>. For project settings, I just chose "Use default gradle wrapper (recommended)", which seems to cause a predefined set of tasks to be created in the Gradle tool window such as "compile", "build", "clean", etc.</li> <li>It turns out that the depended packages need to be separately specified in IntelliJ IDEA in addition to <code>build.gradle</code>. Namely, download the <code>com.google.guava</code> library by following <a href= "http://www.jetbrains.com/idea/webhelp/downloading-libraries-from-maven-repositories.html"> the instruction in documentation</a> -- I picked <code>com.google.guava:guava:17</code> (format is <code>package:artifact:version</code>) to download. (Warning: in IntelliJ IDEA 13.1, I found that one sometimes need to hit the magnifier icon multiple times for it to find a specific artifact from Maven. So don't get confused if it does not find it the first time.)</li> <li>Add the library as a "project library" (by following the automatically prompted window after step 2) or as a global library, by following the documentation instruction <a href= "http://www.jetbrains.com/idea/webhelp/configuring-project-and-global-libraries.html"> "Configuring Project and Global Libraries"</a>.</li> <li>Specify that your Java module depends on the <code>com.google.guava</code> package, following the documentation instruction <a href= "http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html"> "Configuring Module Dependencies and Libraries"</a>;</li> <li>If the IDE still reports "Cannot resolve symbol 'google'" and highlights 'google' as red in <code>import com.google.common.base.Strings</code>, one may try using <code>File | Invalidate Caches / Restart …</code> to force the rebuilding of syntax highlighting in the editor window.</li> <li>One can then open the Gradle tool window, and run the various Gradle tasks such as "compile", "build", and "clean".</li> </ol> <h2>Run Gradle tasks from IntelliJ IDEA Gradle Tool Window</h2> <p>The official <a href= "http://www.jetbrains.com/idea/webhelp/gradle-tool-window.html">IntelliJ IDEA documentation ''Gradle Tool Window''</a> to get an introduction. Hitting <code>build</code> under "All tasks" is equivalent to running <code>gradle build</code> at UNIX command line. It generates <code>/build</code> under project root path. Note JUnit test report is at <code>/build/reports/tests/</code>; Similarly, <code>compileJava</code> compiles Java and <code>javadoc</code> creates Javadoc pages in <code>/build/javadoc/</code>. See <a href= "http://www.gradle.org/docs/current/userguide/java_plugin.html">Gradle documentation</a> for the list of Gradle tasks.</p> <h2>References</h2> <ul> <li><a href="http://spring.io/guides/gs/gradle/">Spring Framework guides ''Building Java Projects with Gradle'': http://spring.io/guides/gs/gradle/</a></li> <li> http://www.gradle.org/docs/1.12/userguide/tutorial_java_projects.html</li> </ul> Installing and configuring IntelliJ IDEA http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_intellij_idea/ http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_intellij_idea/ IntelliJ IDEA active computing configuration documentation draft installation note plugin software tool Tue, 16 May 2017 23:59:39 +0000 2017-05-16T23:59:39Z <h2>Installation on Linux</h2> <p>Restore configuration directory <code>$HOME/.IntellJIdea14/</code>.</p> <h2>Configuration</h2> <ul> <li><a href= "https://www.jetbrains.com/pycharm/help/configuring-color-scheme-for-consoles.html"> Configure font for console</a>. I use font 'Source Code Pro for Powerline' and size 14.</li> </ul> <h2>Plug-ins</h2> <ul> <li> <p><a href= "http://plugins.jetbrains.com/plugin/7253?pr=idea">Pegdown Doclet for IDEA</a>: writing documentation using Markdown. See my example using Markdown in Javadoc <a href= "https://github.com/lumeng/repogit-gradlehelloworld/">here</a> (note <a href= "https://github.com/lumeng/repogit-gradlehelloworld/blob/master/build.gradle"> <code>gradle.build</code></a> and <a href= "https://github.com/lumeng/repogit-gradlehelloworld/blob/master/src/main/java/net/meng6/gradlehelloworld/Main.java"> <code>Main.java</code></a>).</p> </li> <li> <p><a href= "http://plugins.jetbrains.com/plugin/7232?pr=idea">Mathematica Support</a>, develop Mathematica / Wolfram Language code in IntelliJ IDEA.</p> <ul> <li>Preferences | Editor | Coding Style | Mathematica: set tab size to '4'.</li> </ul> </li> <li> <p><a href="https://plugins.jetbrains.com/plugin/7624">Mathematica REPL</a>, connect IntelliJ IDEA to Mathematica kernel.</p> </li> <li> <p>MultiMarkdown or Markdown (from the "Browse repositories ..." menu)</p> </li> <li> <p>IntelliJ-Haskell (from the "Install JetBrains plugin..." menu)</p> </li> </ul> <h2>References</h2> <ul> <li><a href= "http://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse%3F"> Eclipse Wiki: FAQ How do I increase the heap size available to Eclipse?</a></li> </ul> Installing and configuring Mathematica http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_mathematica/ http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_mathematica/ computing configuration documentation installation mathematica note software tool Tue, 16 May 2017 23:59:39 +0000 2017-05-16T23:59:39Z <h2><code>$UserBaseDirectory/Kernel/init.m</code></h2> <p>Make a symbolic link from a version controlled <code>init.m</code> to <code>$UserBaseDirectory/Kernel/init.m</code>. It 1) defines some environment variables such as</p> <pre> <code>SetEnvironment["$DropboxDirectory" -&gt; FileNameJoin[{$HomeDirectory, "Dropbox"}]] </code></pre> <p>and 2) loads some packages that I use frequently enough that loading them every time is convenient:</p> <pre><code>&lt;&lt; meng` </code></pre> <h2> <code>$UserBaseDirectory/SystemFiles/FrondEnd/Stylesheets</code></h2> <p>Make a symbolic link from a version controlled directory of stylesheets <code>path/to/Stylesheets/</code> to <code>$UserBaseDirectory/SystemFiles/FrondEnd/Stylesheets</code> so your own stylesheets is readily accessible from menu Format &gt; Stylesheets and you can keep them update-to-date with its version control repository.</p> <h2>Install SSL certificates</h2> <p>Sometimes, in order to operate with some Web sites with functions like <code>URLFetch</code>, additional SSL certificates associated with the site needs to be appended in</p> <pre> <code>FileNameJoin[{$InstallationDirectory, "SystemFiles", "Links", "HTTPClient", "SSL", "cacert.pem"}] </code></pre> <p>This will allow HTTPClient to use the SSL certificate for authentication.</p> <h2><code>FrequentlyRunCommands.nb</code></h2> <p>I have a notebook where I record all the frequently run commands for quick reuse. It can be set to automatically open when Mathematica starts.</p> <ul> <li>Format → Option Inspector</li> <li>choose "Global Preference"</li> <li>Global Options → File Locations → AutoOpenNotebooks</li> <li>Set value to <code>"/path/to/notebook.nb"</code>; separate notebooks by linebreaks</li> </ul> <h2>Preferences</h2> <h3>Mail server</h3> <ul> <li>Preferences &gt; Internet Connectivity &gt; Mail Settings.</li> </ul> <h3>Interface</h3> <ul> <li>Preferences &gt; Interface &gt; Show open/close icon for cell groups</li> </ul> <h2>Uninstalling</h2> <p>See <a href="http://support.wolfram.com/kb/12473">Wolfram documentation</a>.</p> <p>When having multiple versions installed, to uninstall one of them, delete</p> <ul> <li><code>/usr/local/Wolfram/Mathematica/VERSION</code></li> </ul> <p>Replace <code>VERSION</code> with the version number you would like to delete.</p> Permission of .ssh files http://meng6net.localhost/blog/permission_of_.ssh_files/ http://meng6net.localhost/blog/permission_of_.ssh_files/ computing journal note permission ssh tool Thu, 26 Feb 2015 00:32:53 +0000 2017-05-16T23:59:39Z <p>A brief note about the file permissions of <code>$HOME/.ssh</code> files:</p> <pre><code>$ ls -la ~/.ssh total 136 drwx------ 17 meng _lpoperator 578 Feb 8 11:54 . drwxr-xr-x+ 115 meng _lpoperator 3910 Feb 25 16:10 .. -rw------- 1 meng _lpoperator 1671 Feb 8 11:54 config -rw------- 1 meng _lpoperator 1631 Jan 28 21:55 config~ drwxr-xr-x 4 meng _lpoperator 136 Oct 27 15:16 git-annex -rw------- 1 meng _lpoperator 3243 Jan 28 20:47 id_rsa_work -rw-r--r-- 1 meng _lpoperator 748 Jan 28 20:47 id_rsa_work.pub -rw------- 1 meng _lpoperator 1743 Jan 15 2012 id_rsa_lumengdev -rw-r--r-- 1 meng _lpoperator 402 Jan 15 2012 id_rsa_lumengdev.pub -rw-r--r-- 1 meng _lpoperator 10174 Feb 19 10:37 known_hosts -rw-r--r-- 1 meng _lpoperator 7577 Oct 9 15:29 known_hosts~ </code></pre> <ul> <li><code>$HOME/.ssh</code> folder should have permission <code>700</code>.</li> <li><code>config</code> and private/secret key files <code>id_rsa_XXX</code> should have <code>600</code>.</li> <li><code>known_hosts</code> and public/shared key files <code>id_rsa_XXX.public</code> should have <code>644</code>. And it's fine to have serveral pairs of private/secret and public/shared key files.</li> </ul> <h2>Check the default permissions of <code>.ssh</code></h2> <p>Run <code>ssh &lt;host&gt;</code> will create <code>$HOME/.ssh</code> and <code>$HOME/.ssh/known_hosts</code> file and add an entry for the <code>&lt;host&gt;</code> in it. Running <code>ssh-keygen</code> will create the public/shared and private/secret key pair files: <code>$HOME/.ssh/id_rsa.pub</code> and <code>$HOME/.ssh/id_rsa</code>. Their default permissions are</p> <pre><code>16:24:06 meng@mycomputer:~/.ssh$ ls -la total 24 drwx------ 5 meng _lpoperator 170 Feb 25 16:24 . drwxr-xr-x+ 116 meng _lpoperator 3944 Feb 25 16:23 .. -rw------- 1 meng _lpoperator 1766 Feb 25 16:24 id_rsa -rw-r--r-- 1 meng _lpoperator 404 Feb 25 16:24 id_rsa.pub -rw-r--r-- 1 meng _lpoperator 414 Feb 25 16:23 known_hosts 16:24:11 meng@mycomputer:~/.ssh$ ssh -version OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011 </code></pre> <h2>References</h2> <ul> <li> http://superuser.com/questions/488718/permissions-on-ssh-causing-problems</li> </ul> /blog/permission_of_.ssh_files/#comments