Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts

Saturday, May 17, 2014

Changing the Java version Netbeans runs on

I had to install Oracle JDK in my Crunchbang when I faced this. Found no GUI way for this Googled it. A Stackoverflow page shows this. [http://stackoverflow.com/questions/6950960/how-to-set-the-jdk-netbeans-runs-on]
The file where this is defined is located in
/usr/local/netbeans-{version}/etc/netbeans.conf
There locate the line that starts with
netbeans_jdkhome=
And make it
netbeans_jdkhome="{where you've placed your java installation i.e. [/usr/lib/jvm/jdk1.8.0]}"

Wednesday, April 30, 2014

Fixing Netbeans font problem in Linux

Netbeans shows really awful fonts when you run it on Linux based systems. The reason behind is not actually Linux itself. It's the default arguments used to invoke the Java stuff that Netbeans uses. It, by default, never invokes Anti Aliasing. Thus for, the ugly fonts. Time to fix this. Source [ https://thomashunter.name/blog/enabling-anti-aliasing-in-the-netbeans-editor/ ]

ATTENTION: The following method will always start Netbeans with Anti aliasing on. If you want otherwise, you should try using the extra arguments with the command you use to invoke Netbeans.

1. First locate 'netbeans.conf'. I did that using the command
locate netbeans.conf
But, it usually is found in the directory
/usr/local/netbeans-[version]/etc/netbeans.conf

2. Open the file and look for the line
netbeans_default_options=

3. Between the quotes, you'll see some Java related arguments. What you have to do is, make the line look like this
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m
-J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true
-J-Dsun.java2d.noddraw=true -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=on"

Saturday, September 29, 2012

11821 - High-Precision Number

import java.util.Scanner;
import java.math.BigDecimal;

public class Main {
  public static void main(String[] args) {
    
    Scanner input = new Scanner(System.in);
    int n;
    BigDecimal val;
    n = input.nextInt();
    
    while ( n-- > 0 ) {
      BigDecimal sum = new BigDecimal("0");
      while ( true ) {
        val = input.nextBigDecimal();
        if ( val.equals(BigDecimal.ZERO) ) break;
        
        sum = sum.add(val);
        
      }
      
      int i = new Integer(0);
      
      char out[] = sum.toString().toCharArray();
      
      int len;
      
      for (len=out.length-1 ; len>0 && out[len]=='0' ; len--);
      if (len>0 && out[len]=='.') len--;
      for (i=0 ; i<=len ; i++) {
        System.out.print(out[i]);
      }
      System.out.println();
      
    }
    
  }
}

Friday, September 16, 2011

[UVa] 495 - Fibonacci Freeze

import java.util.Scanner;
import java.math.BigInteger;
/**
 *
 * @author Tafhim
 */
public class Main {

    
    public static void main(String[] args) {
        
        BigInteger[] fibs = new BigInteger[5004];
        fibs[0] = BigInteger.ZERO;
        fibs[1] = BigInteger.ONE;
        for (int i=2 ; i<=5000 ; i++)
        {
            fibs[i] = fibs[i-1].add(fibs[i-2]);
        }
        Scanner input = new Scanner(System.in);

        int q;

        while (input.hasNext())
        {
            q = input.nextInt();
            System.out.printf("The Fibonacci number for %d is %d\n",q,fibs[q]);
            
        }
    }
}

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...