Showing posts with label Tools. Show all posts
Showing posts with label Tools. Show all posts

Thursday, 11 June 2020

New Windows Terminal

Windows have recently introduced a new tabbed terminal which allows different terminal types to be used within one main window.  This is a huge improvement over having a number of cmd prompts open or even using Console2.

To make the new terminal even better you can also add in other terminals that you want to open as a tab.  Using this functionality with Git Bash is a good way to go.

Add Git Bash

Open the terminal and click the down arrow in the menu bar.  Choose Settings.  Notepad should open and the settings can now just be edited there.  To add Git Bash as an option edit the settings and simply add the Git Bash settings as below

  {
      // Make changes here to the gitbash profile.
      "guid": "{00000000-0000-0000-0000-000000000001}",
      "name": "Git Bash",
      "commandline": "C:\\Program Files\\Git\\bin\\bash.exe -i -l",
      "hidden": false,
      "icon" : "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
      "startingDirectory" : "%USERPROFILE%"
  },

If you want to make Git Bash the default then you just change the defaultValue setting towards the top of the file

    "defaultProfile": "{00000000-0000-0000-0000-000000000001}",

Save the changes and Terminal will automatically update and Git Bash will be available.

Thursday, 9 February 2017

Eclipse Not Finding com.sun.tools

This is really simple and obvious but took me a while to work out.  I had a maven project which Eclipse would open but one of the maven dependencies has a child of

    <dependency>
        <groupId>com.sun</groupId>
        <artifactId>tools</artifactId>
    </dependency>

The maven plugin couldn't find this dependency and as a result wouldn't build the project, show compilation errors or build unit tests.

It turns out that a recent java installation had changed the path environment variable to put

    C:\ProgramData\Oracle\Java\javapath

at the front of the PATH variable.  The contents of this folder are shortcuts to the runtime (JRE) environment.  This means that when I was starting Eclipse it was running a jre and not a jdk.  Sorting out the PATH environment variable and moving the offending new entry to the end meant that I was using my own JAVA_PATH again which was pointing to the jdk.  Restarting Eclipse then meant that the problem was sorted.

Friday, 22 August 2014

Profiling & jvisualvm

JVisualVm is a really good profiling tool for use with Java.  It is included in the JDK.

To use it on a local running instance then just run it.  All the VMs will appear in the application menu on the left hand side.

Remote
JVisualVM can also be used remotely.  On the machine with the VM to profile, create a policy file which contains the following

// create a policy file called all.policy
grant codebase "file:${java.home}/../lib/tools.jar" {
   permission java.security.AllPermission;

};

Then create a RMI instance on a particular local port (1099 is standard but any port can be used such as 2020)

// Start the rmiregistry

rmiregistry 1099&

And now use jstatd to populate the registry.

// Start jstatd with the policy file above and point it to the rmiregistry

jstatd -J-Djava.security.policy=all.policy -p 1099

Now start jvisualvm on a local machine and connect to port 1099 on the remote machine to view the details.

Within jvisualvm right click on 'Remote' and select 'Add remote host'.  In the hostname add the IP address of the remote machine and in 'Advanced' the port can be change if 1099 isn't used for the rmiregistry or jstatd.

It isn't possible to do everything with a remote connection that you can do with a local connection. For this reason it can be useful to run jvisualvm locally but use X11 forwarding to put the actual application on a remote machine.

Troubleshooting

Sometimes there are connection issues when trying to connect to a remove jstatd.  So check the following

Logs
Look at the jvisualvm logs which can be found in ~/.visualvm/<version>/var/log

Headless
Although jvisualvm can be run with X11 forwarding so it can be a headless environment it has dependencies on some X11 libraries so needs to have a desktop manager installed even if it isn't running. (libXext.so.6)

Firewall
Make sure that any firewall isn't blocking the RMI ports.

RMI address
Sometimes the RMI address needs to be set so try adding

    -J-Djava.rmi.server.hostname=<ip address>

IP version
It is also possible to try to force IPv4 to see if that helps,

    -J-Djava.net.preferIPv4Stack=true 


Other Tools

There are a number of other tools which are useful to ascertaining if there is a memory leak in the heap.  A heap dump can be generated using the jmap command which is part of the jdk

    ./jmap -dump:format=b,file=<filepath> <pid>

This generates a hprof format.  There is a free tool called the Memory Analyser Tool (MAT) which is based on the eclipse platform and can be used to analyse the heap file.

    http://www.eclipse.org/mat/

Tuesday, 19 November 2013

Java Keytool

I constantly forget how to use the keytool so here are some memory joggers!  The keytool app is part of the the standard Java distribution.

These will be added to over time.

List

List the contents of a jks file

    keytool -list -keystore <keystore.jks> -storepass <password>

Remote Keys

Print a certificate for a remote server


   keytool -printcert -rfc -sslserver my.company.com

Copy the output into a file .pem

Import Key

Import a key to a key store.  In this case it is imported into the java default Certificate Authority file (cacerts).  This will prompt for a password for the cacerts file which is 'changeit' by default.

    keytool -importcert -file ./certificate.pem -keystore $JRE_LIB/lib/security/cacerts

Friday, 27 September 2013

JD Eclipse Decompile

JD Eclipse is a brilliant java decompile which very usefully provides line numbers in the decompiled class file.  Unfortunately it is no longer supported or in the Eclipse MarketPlace. To get it running on eclipse copy the two jars

jd.ide.eclipse.win32.x86_64_0.1.3.jar
jd.ide.eclipse_0.1.3.jar

into the eclipse/plugins directory and restart Eclipse.

Once eclipse has restarted go to,

    Window - Preferences - General - Editors - File Associations

Click on 'Class' and then 'Add'.  There is a new option now available called 'Class File Editor'.  Add this and make it the default.  Do the same to the 'Class without Source'.

Once completed the JD-Eclipse class viewer will be used to open class files.

I'd be interested to know if there is anything else around that decompiles like JD Eclipse?  The ByteCode Visualiser in the MarketPlace is good but I want the actual code not the byte code.



Update
After posting this I have found this site with instructions and updates.

http://jd.benow.ca/

Tuesday, 30 July 2013

Soap UI

SoapUI is a brilliant tool for testing web services.  It can be downloaded from http://www.soapui.org/.

Property Transfers

SoapUI allows testing individual calls to a service but also allows multiple requests to be put together to form test cases.  For example, a test case creating and deleting would require the id generated by the first request to be passed to the delete request.  Soap UI's mechanism for doing this is with a Property Transfer.

    Right Click on the Test Steps -> Add Step -> Property Transfer

The transfer is done using XPath by default.  An example of a property transfer is below using the xml

CreateRequest
    <CreateRequest>
        <name>Andy</name>
        <data>123456</data>
    </CreateRequest>

CreateResponse
    <CreateResponse>
        <id>159</id>
        <name>Andy</name>
        <data>123456</data>
    </CreateResponse>

DeleteRequest
    <DeleteResponse>
        <id>159</id>
    </DeleteResponse>

Here the property transfer is between the CreateResponse and the DeleteRequest.  In SoapUI this will look like,

    Source: Create      Property: Response
    declare namespace myns='http://www.me.com/example';
    //myns:CreateResponse/id

    Target: Delete      Property: Request
    declare namespace myns='http://www.me.com/example';
    //myns:DeleteRequest/id

It is possible to include the whole <id>159</id> or to just transfer the value you can check the

    Transfer text content

Transfering a whole block of xml can be really powerful but the 'Transfer text content' does keep things simple and allows the transfer of the 'value' only.



Thursday, 13 September 2012

Useful Tools

Here is a list of useful tools that I have come across.  I'm always forgetting what I've found so here is a list!

Development Tools

Toad
http://www.toadworld.com/
Brilliant SQL editor and database management tool.

Console
http://sourceforge.net/projects/console/
Really useful Windows Command wrapper with gives tabs, resizing, etc

MPutty
http://ttyplus.com/multi-tabbed-putty/
Manages multiple putty windows

SoapUI
http://www.soapui.org/
Tool for testing soap services.

IETester
http://www.my-debugbar.com/wiki/IETester/HomePage
Tester to allow rendering in multiple different IE versions.

SourceTree
https://www.sourcetreeapp.com/
Windows app for accessing Git repositories

Text Editors

JEdit
http://www.jedit.org/index.php?page=download
Great cross-platform tool.  Drag to select is cool as is the encoding support.

Textpad
http://www.textpad.com/
Good integration with windows.

Notepad++
http://notepad-plus-plus.org/download
Good general text editor.

Zip / Archive

7-zip
http://www.7-zip.org/
Easily the best free zipper around (IMHO!)

File Transfer

Filezilla
http://filezilla-project.org/
Free FTP file transfer tool - very good.

WinSCP
http://winscp.net/eng/index.php
Another good FTP / SFTP tool.

PC Cleanup

CCleaner
http://www.piriform.com/ccleaner/download
Cleans up temp files and scans and cleans registry.


Audio / Visual

HD Converter
www.koyotesoft.com

Converts HD formats.

Camstudio
http://camstudio.org/
Record video / audio from the activity on your computer.

GIMP
http://www.gimp.org/
GNU Image Manipulation Program.

Audacity
http://audacity.sourceforge.net/
Music file manipulation.

Virus / Malware

Malwarebytes
http://www.malwarebytes.org/
Good malware and virus scanner.

Spybot
http://www.safer-networking.org/dl/
Good spyware killer.

Sophos Anti-rootkit
http://www.sophos.com/en-us/products/free-tools/sophos-anti-rootkit.aspx
Tries to find and remote root-kits from your computer.