Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Sunday, May 30, 2010

javaplugin.so does not exist sub process /usr/bin/dpkg returned an error code (1)

javaplugin.so does not exist sub process /usr/bin/dpkg returned an error code (1)


try:

sudo dpkg --remove sun-j2re1.6

Friday, May 14, 2010

Installing Java 1.4.1 on Ubuntu 9.10 (Karmic Koala)

Installing Java 1.4.1 on Ubuntu 9.10 (Karmic Koala) turned out to be nothing but a pain.

Firstly, Java 1.4.1 has now reached End of Life, so Sun doesn't support it any longer.

1. So, download Java 1.4.2_07 from the archive: http://java.sun.com/products/archive/j2se/1.4.1_07/


2. Then when you try to set the file to executable by 'chmod -x' and then run it, you're likely to get an error message like:

"tail: cannot open `+341' for reading: No such file or directory"

Then something about the download being corrupt.

This is because (according to here) the tail program in Linux has changed slightly since then and has a different syntax.

To get around this, I unzipped the .bin file using 7Zip on a Windows system; but I guess p7zip can be used on a Linux system too.

3. Then I placed the 'j2re1.4.1_07' folder into my /usr/lib/jvm/ folder and did the procedures 5 to 6 as in the previous post.

4. Then finally, manually added the plugin (so that it works in Firefox) to the list of plugins as given in the 'Java Applet Runtime Settings' -> 'View' in the GUI for the ControlPanel command.

Thursday, May 13, 2010

Downgrading Java Version in Ubuntu and Firefox to 6 update 11

Fortunately Ubuntu allows for users to change the Java version used and also run multiple versions of Java. To do this:


1. Download JRE 6u11 from here:
http://java.sun.com/products/archive/j2se/6u11/index.html

2. Chmod +x it. i.e.:
sudo chmod +x jre-6u11-linux-i586.bin

3. Move it to the jvm folder
sudo mv jre-6u11-linux-i586.bin /usr/lib/jvm/

4. cd to that folder and run it

cd /usr/lib/jvm/
sudo ./jre-6u11-linux-i586.bin

5. Now add it to the alternatives:
sudo update-alternatives --install /usr/bin/java /usr/lib/jvm/jre1.6.0_11/bin/java 500

6. Then you can select to use that version of java by running:
sudo update-alternatives --config java

Now that's all well and good; but it will still be running the newer version in Firefox. So:

7. Run the java control panel, by typing:

ControlPanel

Then click on the tab 'Java' and the button 'view' under 'Java Applet Runtime Settings'

From there, you can disable any unwanted Java versions.

8. The plugin inside Firefox's setTest your Firefox java version here:
http://java.com/en/download/help/testvm.xml


Unfortunately my Cisco PIX 501 Manager STILL does not work with this.

Wednesday, May 13, 2009

Class names 'MyApp', are only accepted if annotation processing is explicitly requested

Class names 'MyApp', are only accepted if annotation processing is explicitly requested

Dear oh dear...

I/You forgot to put '.java' on the end of the filename. Thinking you're above all that '.java. stuff huh?

Friday, September 05, 2008

Regular Expression in Java to Strip HTML Tags

Regular Expression in Java to Strip HTML Tags; just for my own reference:

sMyString = sMyString .replaceAll("\\<.*?>","");



Wednesday, July 16, 2008

Replacing Brackets in a String (Java)

Trivial issue really but something I always forget...

sNiceString = sNiceString.replaceAll("\\(", "");

or

sNiceString = sNiceString.replaceAll("\\)", "");


You could probably use a purer regular expression too but this does the job.


Thursday, May 29, 2008

Compiling UTF-8 Encoded Files in Java

If the compiler is giving out warnings like:

"warning: unmappable character for encoding cp1252"

It is best to specify the exact encoding, as in:

javac -encoding UTF-8 JavaSourceFile.java




Friday, September 08, 2006

Java. Pause Method

A nice little method to create a 'pause' effect in Java.


public static void doPause(int iTimeInSeconds){
long t0, t1;
System.out.println("timer start");
t0=System.currentTimeMillis( );
t1=System.currentTimeMillis( )+(iTimeInSeconds*1000);

System.out.println("T0: "+t0);
System.out.println("T1: "+t1);

do {
t0=System.currentTimeMillis( );

} while (t0 < t1);

System.out.println("timer end");

}