• Blog All
  • Mr N
  • Linkblog
  • Home

Mr N

Everything I want to remember

  • Home
  • Contact
  • Log in

Simple way of sharing files on a home network

February 8th, 2010

There are several ways of sharing files between 2 (or more) PCs. The simplest is some sort of removable media such as a memory stick or DVD. You might run into problems if your file is bigger than the size of the memory stick. The trouble with copying files around, is that if more than one person is working on it there will be issues around who has got the latest version. This is where a network comes in handy.

Don’t you need a server to share files? No! You can share a directory of your hard drive with other people and you can both edit the file. This ensures there is only one copy of the file.

It’s so easy even my parents can follow these instructions. First you have to pick a computer to be the server. This is where the files actually live, so you are best off picking the computer with the most free space on it.

  1. On your desktop, double click on My Computer.
  2. This will open the list of devices and hard drives. There is a column for Free Space.
  3. Make a note of the free space, for each local drive.
  4. Make a note of the drive letter, with the most free space.

Do this on both computers to find the machine with the largest free space. The following instructions are to be applied to the computer with the largest amount of free space.

  1. Create a folder at the top level on the drive with the most free space.
  2. Call the folder “shared", so that the address bar in Windows Explorer reads “C:\shared” - where “C:” is the drive letter with the most amount of free space.
  3. Inside Windows Explorer, find the “c:\shared” folder, right-click on it and select Properties.
  4. A window will pop up with information about the folder. Click the Sharing and Security tab.
  5. Click the Share this folder radio button. The Share name will be filled in for you with the name of the folder.
  6. Click the Permissions button to alter how much control you want to give the other person. To give yourself an easier life just set the permissions to Allow Full control to Everyone.
  7. Click Ok until you are back at your desktop.

In order to tell other people what our new share name is, we must find out our network name. This is usually referred to as the hostname.

  1. Use the mouse and click the Windows Start menu.
  2. Select Run…
  3. Type: command and press return.
  4. In the box that opens up type: hostname
  5. Make a note of what the hostname is.
  6. Close the box.

You now have all the pieces needed to construct your share name, which looks like this:

\\david\shared

where david is what my hostname command spat out and shared is the name of the folder we are sharing.

Hurray you have just set up a shared folder on your PC. Next we are going to move to the other machine and set up access to that shared folder.

  1. Load in Windows Explorer.
  2. From the menu bar at the top, select Tools, then Map Network Drive…
  3. Select a drive letter. I usually pick a letter that is furthest from my other drive letters, for example “Z:".
  4. Set the Folder to the share name we constructed above, substituting your hostname in place of mine.
  5. Check the Reconnect at login to make sure your connection doesn’t disappear when you switch off your computer.
  6. Click Finish.
  7. Windows will think about it for a while (I don’t know why but this can take up to a minute).
  8. Windows Explorer will refresh with your new “Z” drive.

Well that was easy wasn’t it!


Tags: networking, simple, support, windows

Posted in Fun, Techie | Send feedback »

Java's File.renameTo fails on Windows

February 2nd, 2010

I had a problem with renaming a properties file. Java’s File.renameTo() always failed and returned false. There was no explanation as to why it failed, so it left me stuck with no idea what to do.

Windows has a different file locking policy to Unix (and everyone else). Under Windows, if a process has a file open no other process can rename, move or delete the file until that process has closed all handles to it. As if that wasn’t bad enough, if you do leave a file open and your code finishes running the file will still be locked after an unknown amount of time. It could be 30 seconds or it could be never. Hurray for windows :(

So you must ensure that the file you are trying to rename is completely closed. My problem turned out to be in the loading and saving of properties files. Almost all the example code you download relating to reading and writing properties is wrong. Properties.load() and Properties.store() both take file streams. If the stream is still open then the file will be locked.

Most of the examples tell you to load the properties like this:

Java:

Properties properties = new Properties();
properties.load(new FileInputStream("filename.properties"));

and save them like this:

Java:

Properties properties = new Properties();
properties.store(new FileOutputStream("filename.properties"));

I was under the impression that store and load closed down the stream after they had done their business, but this is not the case. The streams are left open. So when you use the methods above to create a file and read from a file you are leaving the handle open. What’s worse is that because the FileInputStream and FileOutputStream are in-line there is no reference available to close the streams down - and you are stuffed!

The correct method of reading from a Properties file is:

Java:

FileInputStream in = null;
Properties properties = new Properties();
try
{
  in = new FileInputStream("file.properties");
  properties.load(in);
}
finally
{
  if (in != null) in.close();
}

and similarly, writing to a Properties file:

Java:

FileOutputStream out = null;
Properties properties = new Properties();
try
{
  out = new FileOutputStream("file.properties");
  properties.store(out);
}
finally
{
  if (out != null) out.close();
}

Now, after reading and writing, you have explicitly closed the file and you are free to rename the file without error.


Tags: java, renameto, windows

Posted in Techie | Send feedback »

Automatically showing the Editor's file in Eclipse's Package Explorer

January 28th, 2010

Searching on Google can be really easy as long as you pick the right words to search for. What if you’re not sure what you are looking for or what if you don’t know what the thing (or action) is called?

I was using Eclipse (the Java language editor) in its vanilla form and when I switched to Spring Tool Suite (STS) (which is a re-badged version of Eclipse) I found that the feature I thought was so useful had been switched off.

I knew the feature I wanted to switch on but I didn’t know what it was called! So I’m writing this article so that others might find it and not have to spend 2 weeks looking for it.

When the Eclipse feature is switched on, selecting a file to edit will open the representation of the file in the Package Explorer pane. As you open more files and switch to them in the editor pane, the focus moves in-line inside the Package Explorer.

This is called Linking or Link with Editor. You are linking the Package Explorer with the Editor pane. There is a double arrow icon at the top of the Package Explorer that toggles this behaviour:


Tags: eclipse, sts, support

Posted in Techie | Send feedback »

Integrating a better file comparer than clearcase offers

January 26th, 2010

Wonderful though Clearcase is, its support tools leave a lot to be desired. Take the file comparison application that comes bundled. It only flags lines which have changed, so you often have to spend a couple of moments scanning the line to spot the changes. There are loads of file comparers out there to choose from. So here is how to integrate it with Clearcase.

The simplest way is to find a file comparer with Clearcase integration capabilities like KDiff3. The integration is simple:

  1. Download KDiff3 and install.
  2. Run it up.
  3. From the menu select Settings->Configure KDiff3.
  4. Go into the Operation tab.
  5. Click Integrate with Clearcase.
  6. Click Ok.

Simple, but what if your file comparison tool doesn’t have an integrate with Clearcase button? Changing the Clearcase hooks is quite straight forward. The mapping file exists in:

<installation-root>\ClearCase\lib\mgrs\map

The file is keyed in extension (or class) and action, so replace the following lines in the map file.

_rftdef            xcompare  C:\Program Files\KDiff3\kdiff3.exe
_rftmap            xcompare  C:\Program Files\KDiff3\kdiff3.exe
_rftvp             xcompare  C:\Program Files\KDiff3\kdiff3.exe
_xml               xcompare  C:\Program Files\KDiff3\kdiff3.exe
_xml               xmerge    C:\Program Files\KDiff3\kdiff3.exe
_xml2              xcompare  C:\Program Files\KDiff3\kdiff3.exe
_xml2              xmerge    C:\Program Files\KDiff3\kdiff3.exe
_xtools            xcompare  C:\Program Files\KDiff3\kdiff3.exe
text_file_delta    xcompare  C:\Program Files\KDiff3\kdiff3.exe
text_file_delta    xmerge    C:\Program Files\KDiff3\kdiff3.exe
whole_copy         xcompare  C:\Program Files\KDiff3\kdiff3.exe
whole_copy         xmerge    C:\Program Files\KDiff3\kdiff3.exe
z_text_file_delta  xcompare  C:\Program Files\KDiff3\kdiff3.exe
z_text_file_delta  xmerge    C:\Program Files\KDiff3\kdiff3.exe
z_whole_copy       xcompare  C:\Program Files\KDiff3\kdiff3.exe
z_whole_copy       xmerge    C:\Program Files\KDiff3\kdiff3.exe

Tags: clearcase, diff, kdiff, support

Posted in Techie | Send feedback »

Finding which files are on a clearcase branch without a label

January 25th, 2010

The clearcase reports that come out of the box only let you find out the files that have changed between 2 labels. What if you haven’t applied the other label yet, or you are writing release notes and the official labelling hasn’t taken place yet?
If you have applied a label, how do you know which files have changed since then.

Open a command line and switch to the view and directory path you are interested in. Issue the following command:

cleartool find . -cview -version “!lbtype(MY_LABEL)” -print

where:
‘.’ is from the current directory,
-cview is current view
-version “!lbtype(MY_LABEL)” is look for versions without a label called MY_LABEL
-print is what to do with them.


Tags: branch, clearcase, find

Posted in Techie | Send feedback »

1 2 3 4 5 6 7 8 9 10 11 ... 25 >>
  • February 2010
    Mon Tue Wed Thu Fri Sat Sun
     << <   > >>
    1 2 3 4 5 6 7
    8 9 10 11 12 13 14
    15 16 17 18 19 20 21
    22 23 24 25 26 27 28
  • Mr N

  • All the little snippets of information I don't want to forget.

    • Recently
    • Archives
    • Categories
    • Latest comments
  • Search

  • Categories

    • All
    • Fun
    • Techie
  • XML Feeds

    • RSS 2.0: Posts, Comments
    • Atom: Posts, Comments
    What is RSS?
    • Free Conference Call Service
  • Blog Catalog

blog soft

©2010 by David Newcomb | Contact | Design by Michael | Credits: blog tool | UK web hosting | authors