Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Java native interface



  A simple tutorial on writing Java native program

Java provides Java Native Interface(JNI) to enable developers to write programs which can utilize the underlying native libraries of the operating system. The benefits of writing native code are that they normally provide better performance compared to Java codes. Sometimes if you want to utilize some system specific functions you may also want to use JNI. One main drawback of writing native code is that your application may not be platform independent anymore. This is not what Java is desi...

   Java native interface, JNI, Native code, Sample     2015-08-15 08:28:15

  Understanding abstract interface in Java

Have you read about an interface declaration as public abstract interface InterfaceName in Java? At the first glance, is it a weird declaration? Why should we declare an interface as abstract? For example, we may see below code in some projects: public abstract interface MyInterface { public void check(); public abstract boolean check(boolean really); } Actually here abstract is redundant, an interface is implicitly abstract, we no need to put an abstract in front of interface. But it do...

   Java,abstract interface     2014-08-18 23:07:27

  Different ways to print "Hello world" in Java

This post is not about best practice to print "Hello world" in Java, it is about exploring different capabilities offered by Java. Also there are articles about printing "Hello world" in different programming languages, but this post is not about that. Standard literal The most commonly used way is to use System.out to print"Hello world". System.out.println("Hello world"); Enumeration An enumeration can define a set of values belonging to one category. For example, an enumeration for all months ...

   JAVA,FEATURE     2016-05-21 21:49:48

  How to check whether a struct implements an interface in GoLang

Unlike other programming languages like Java, when implementing an interface in GoLang, there is no syntax like below to explicit tell the relationship: type I interface { } type A struct implements I { } When looking at the code or running the code in GoLang, it might lead to a case one doesn't know whether a struct implements interface before trying to use it as some interface. According to GoLang spec, as long as a struct implements all functions of an interface, it is considered as having i...

   GOLANG,INTERFACE,IMPLEMENTATION,CHECK     2020-05-03 00:05:54

  The difference between System.load and System.loadLibrary in Java

When writing code using native library in Java, normally the first step is loading some native library. static{   System.load("D:" + File.separator + "Hello.dll"); } JDK provides two ways to load libraries: System.load(String filename) System.loadLibrary(String libname) This post will try to explain the differences of these two ways. According to Java Doc on System.load(), it has below description. Loads the native library specified by the filename argument. The filename a...

   NATIVE,JNI,JAVA,SYSTEM.LOAD,SYSTEM.LOADLIBRARY     2019-02-05 05:49:28

  Check file readability in Java

File operation is quite platform dependent. Although Java is a cross platform programming language, the file operation in Java is also platform dependent. The obvious evidence is the file permission check. In Java, we can call canRead(), canWrite() and canExecutable() to check whether the program can read, write or execute the file specified. However, on Windows, when we call canRead() on a File object, we may get unexpected result. Actually, on Windows, when we call canRead() on a File object, ...

   Java,Files,Readable,Check     2013-12-05 06:10:15

  Top 10 essential Java classes

When we write Java programs, we will frequently use some classes such as java.lang.String. There are some essential Java classes which we may use frequently, there is no strict rules for the selection of essential Java classes, in fact there are no rules followed. It depends on what projects you are doing or what you have done,, so every one may have his own choices about the top essential Java classes in his mind. Here we list the top 10 essential Java classes you may agree with.1. java.lang.St...

   Java,class,essential class,top 10     2012-06-04 09:44:19

  this keyword in Lambda expression in Java 8

Since the release of Java 8, people are excited to see a big feature added to this language which is existing in other languages for a long time -- Lambda expression. The introduction of lambda expression in Java 8 gives people an easy way or a vertical to horizontal way to solve problems. There are many posts on the Internet which shows how to use lambda expression in Java, such as Lambda Quick Start and Java 8 Lambda Expressions Tutorial with Examples. In this post, we will only focus on the t...

   THIS,LAMBDA EXPRESSION,JAVA 8     2014-06-01 03:57:05

  JavaScript JVM runs Java

The world of software is made slightly crazy because of the huge flexibility within any computer language. Once you have absorbed the idea of a compiler written in the language it compiles what else is there left to gawp at? But... a Java Virtual Machine JVM written in JavaScript seems like another level of insanity.In fact it is a quite reasonable idea which is only made mad by the usual positions that Java, the top dog, and JavaScript the underling, usually occupy. Java is compiled not to mach...

   JavaScript,JVM,BicaVM,Cross platform,JavaScript written JVM     2011-11-22 02:51:38

  Java AbstractMethodError explained and demonstrated

According to Oracle Java API documentation, AbstractMethodError is a kind of runtime error where the application is having some incompatible changes which leads to a missing implementation of an abstract method. Below is the official description. Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last co...

   JAVA,ABSTRACTMETHODERROR     2016-07-22 22:03:20