Wednesday, 4 September 2013

Installing i386 32 bit rpm files in amd 64 bit ubuntu

In my office, I am using ubuntu linux. But one particular piece of software developed by our company was available in msi and rpm formats. msi is microsoft installer available for windows. For linux, rpm can be used. I don't know how to install rpm files in ubuntu. After searching in web and doing some trials, I found the following steps were helpful.

1) First install Alien. This is the definition of Alien from ubuntu site. Alien converts an RPM package file into a Debian package file or Alien can install an RPM file directly. 

2) Then if the rpm is for 32 bit, you will have little bit tough time. The following steps are one way to solve this issue.
i386-32 bit rpm install on amd64 bit ubuntu (different architecture and different processing machines)

2a)    To install 32 bit apps on 64 bit ubuntu, we need to have installed "ia32-libs". The original source is here.

2b) Then we need to convert the rpm to tgz (tar.gz) format. Straightforward conversion from rpm to deb format can cause issues if the package was meant for i386 and you are trying to install in amd64 bit. It will say architecture is incompatible like "<filename.rpm> is for architecture i386 ; the package cannot be built on this system".  This is because the package is built for i386 but we are trying to install in amd 64 bit.  To overcome this, we need to first perform the conversion from rpm to tgz.
sudo alien --to-tgz <file name.rpm>

2c) The above step gives us tgz file. This can be then converted to deb format by using alien command again.
sudo alien --to-deb <filename.tgz>
Then the usual procedure to install deb  can be used. That is use "dpkg -i <file name.deb>.
 
References:

Tuesday, 27 November 2012

Java - public static final String constant vs Enum constant

Let me prove you that why we need to use as much enum as possible instead of public static final String.

Constant.java

public class Constant
{

    public static final String TEST_CONST_STRING = "TestConstString";
}


EnumConstant.java

public enum EnumConstant
{
    TEST_CONST_STRING("EnumTestConstString");

    String str;

    EnumConstant(String str)
    {
        this.str = str;
    }

    public String getValue()
    {
        return str;
    }
}


Consumer.java

public class Consumer
{
    public static void main(String[] args)
    {
        System.out.println(Constant.TEST_CONST_STRING);
        System.out.println(EnumConstant.TEST_CONST_STRING.getValue());
    }
}



Assume all the 3 java files are present in the same directory. Now do the following:

a) Run javac Constant.java EnumConstant.java Consumer.java

b) Run java Consumer
Now obviously TestConstString and EnumTestConstString gets printed in the console.

c) Now change the "TestConstString" in Constant.java to "TestConstStringChanged" and "EnumTestConstString" to "EnumTestConstStringChanged".

d) Run javac Constant.java EnumConstant.java. Don't compile Consumer.java.

e) Run java Consumer.
Now you can see that TestConstString and EnumTestConstStringChanged gets printed in the console.

TestConstStringChanged doesn't get printed.

Reason: When we change any value pointed by public static final String, then we need to recompile all the files which depend on this string. In case of Enum, we don't need to compile the dependent files.