Adding a Weka shortcut under Fedora Linux

…and scaling it up for High DPI screens.

I’ve recently bought the developer edition of the XPS13 with a highDPI screen and needed to install WEKA for a course I’m doing. When I first ran it from the command line it looked like a tiny little thing in the top left of the screen however a small amount of DuckDuckGo-ing resulted in the correct way of dealing with it.

I’m using Fedora (and gnome) so create a Desktop file for Weka with this pasth and filename: ~/.local/share/applications/weka.desktop

I’ve put my weka jar file in a directory called Programs in my home folder.

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Weka
Comment=Weka Application
Exec=java -Dsun.java2d.uiScale=3.5 -jar /home/mike/Programs/weka-3-8-1/weka.jar
Icon=/home/mike/Programs/weka-3-8-1/weka.ico
Terminal=false

Save it and you should be good to go. Make sure you have the Latest Java installed (I’m using Java9 straight from Oracle). Oh! change the uiScale factor to suite your preference.

Simple Java Insertion Sort

package insertionshort;
public class InsertionShort {
    public static void main(String[] args) {
        int[] a = {123, 235, 23, 46, 34, 2, 45, 235, 25, 65, 46, 2345, 25, 246, 24, 5246, 24, 6};
        intInsertionSort(a);
    }
    public static void intInsertionSort(int[] a) 
    {
        for (int i = 0; i < a.length; i++) {
            int temp = a[i];
            int j;
            for (j = i - 1; j >= 0 && temp < a[j]; j--) 
            {
                a[j + 1] = a[j];
            }
            a[j + 1] = temp;
            for (int f = 0; f < a.length; f++) 
            {
                System.out.print(a[f] + "\t");
            }
            System.out.println();
        }
    }
}

connecting using jdbc and pulling back some data

Connecting to some sql servers with jdbc.

Download the JDBC driver for your databases and add them to the project in eclipse (or whatever) then:

import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class DbConnect{
public static void main(String args[]){
	String dbtime="";String db_connect_string="";String db_userid="";String db_password="";String query="";
	try {
	//Class.forName("com.mysql.jdbc.Driver");
	Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	int choose=2;
	switch (choose)
	{
	case 0:
		db_connect_string="jdbc:mysql://yourMySQLServerNameHere/yourMySQLData";
		db_userid="ooooohyourusername";
		db_password="waaaaaayYourPassword";
		query = "Select top 10 * FROM YourTable";
		break;
	case 1:
		db_connect_string="jdbc:sqlserver://yourSQLServerNameHere;databaseName=yourDatabaseName";
		db_userid="ooooohyourusername";
		db_password="waaaaaayYourPassword";
		query = "Select top 10 * FROM YourTable";
		break;		
	}
	Connection con = DriverManager.getConnection(db_connect_string,db_userid, db_password);
	Statement stmt = con.createStatement();
	ResultSet rs = stmt.executeQuery(query);
	int rn=0;
	while (rs.next()) {
	dbtime = rs.getString(1)+"  "+rs.getString(2)+"  "+rs.getString(3)+"  "+rs.getString(4)+"  "+rs.getString(5);
	System.out.println(rn+" : "+dbtime);
	rn++;
	} con.close();	
} //end try
catch(ClassNotFoundException e) {e.printStackTrace();}
catch(SQLException e) {e.printStackTrace();}
}
}