Search This Blog

Monday, February 21, 2011

Manual DVD eject MACOSX

if the DVD icon in Finder is gone you could use

drutil eject

within a terminal.

Wednesday, February 16, 2011

Creation and usage of SSH Identity Files for OpenSSH or SFTP

Here is a quick step by step list how to setup an use an identity file with SSH or SFTP


1. Create a private and a public key with 
    ssh-keygen -t dsa

2. Now you should have something like 
   id_dsa and id_dsa.pub

3. Add the content of the public key file id_dsa.pub to the users .ssh/authorized_keys file folder on the host you want to connect with 
   cat id_dsa.pub >> .ssh/authorized_keys

4. Now you should be ready to connect to the host with i.e.
             sftp -o IdentityFile=id_dsa user@host
     ssh  -i id_dsa user@host


Thursday, February 3, 2011

HTC Desire HD und die gelben Bilder

Falls ihr euch über die gelblichen Bilder von eurem HTC Desire HD wundert, dann geht einfach mal in das Menu der Kamera Anwendung. Dort befindet sich der Menupunkt Weissabgleich. Hier ist per Default Tageslicht eingestellt. Stellt es mal auf Auto. Das wirkt Wunder :-)

Wednesday, June 2, 2010

Command prompt from here

Well sometimes I need a cmd right from the directory in the explorer within Windows. Microsoft offered the so called MS Powertoys, which have had a feature called command prompt from here. What that does was just a simple registry entry, which added an entry to the folder context menu. If you want to have such an extension you could easily add the following to your registry:



[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\command prompt]
@="Devenv from here"


[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\command prompt\command]
@="C:\\bin\\devenv.cmd %L"

(Just paste the lines above into a file with a .reg extension and click on it)

Now you could create a file called C:\bin\devenv.cmd and add you favorite Path extensions or variables. After adding the two entries to your registry you will see a new entry when you right click on a folder "Devenv from here".

Tuesday, April 20, 2010

Eclipse Galileo 3.5.1 Index Problems

After a while working with eclipse Galileo SR1 the startup of the IDE slows down. Beside this I frequently got an error like that:

Class file name must end with .class

To fix this I've done the following:
  1. Close Eclipse
  2. Delete /.metadata/.plugins/org.eclipse.jdt.core/*.index
  3. Delete /.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt
  4. Start Eclipse again
The eclipse bug list mentioned the behaviour in defect 286379 fixed for Milestone 3.6 M3.

Wednesday, March 17, 2010

Instantiate a Generic Type in Java

Once you used generics for a while you might stumble upon the following question:

public class MySample {
       private     T    mySample = null;


       public MySample() {
               mySample = new T();  // well this would be fine, but it doesn't work because the compiler doesn't know the type at this time!
      }
}

Ok, fair enough the compiler doesn't know if T is an interface or an object and couldn't instantiate the type. If your T is a class you could solve the question with this:



public class MySample {
       private     T    mySample = null;

       public MySample(Class _class) {
               mySample = _class.newInstance();
      }
}


This should work with the little overhead of specifying the class in the generic and the constructor:



  MySample  sample = new MySample(Whatever.class); 

  

Tuesday, February 16, 2010

Java File Format Version

Once you're moving around for a while in Java based environments you might have seen an error like this

java.lang.UnsupportedClassVersionError: Bad version number in .class file


If you hit this kind of error than its time to realize that Java byte code might differ between JDK versions :-) You'll find a long list of explanations about the Java Class file format all over in the web (http://en.wikipedia.org/wiki/Class_%28file_format%29).
Here is a list of class file versions and the corresponding JDK

J2SE 6.0 = 50 (0x32 hex),
J2SE 5.0 = 49 (0x31 hex),
JDK 1.4 = 48 (0x30 hex),
JDK 1.3 = 47 (0x2F hex),
JDK 1.2 = 46 (0x2E hex),
JDK 1.1 = 45 (0x2D hex).

Ok thanks for the list but how do I get the version out of an existing class file?
Answer:

 javap -v MyClass | more

this will print out something like this:

 class MyClass extends java.lang.Object
  minor version: 0
  major version: 50
....