Java learning: Hello World program with java

Recently, I begin to use java in my work. I used to c++ for more than 10 years.

Programmer start every thing begin with Hello World

public class HelloWorld {                                                       
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

Java main function, must be in a public class

 public static void main(String[] args) {} 

Compile HelloWorld

javac HelloWorld.java

Execute HelloWorld

java HelloWorld
remember, not java HelloWorld.class
otherwise, you will got below error
Error: Could not find or load main class HelloWorld.class

Java learning : how many classes defined in java source, how many .class byte code files will be generated after compile via javac

One java source file generate one .class byte code file ?

False.
I thought one java source code file will generate only one .class byte code file, since I am a c++ programmer for about 10 years.
The correct answer is
how many classes defined in java source, how many .class byte code files will be generated after compile via javac
public class HelloWorld {
    class HelloInternal {
    }
}

enum HelloEnum {
}

interface HelloInterface {
}
javac HelloWorld.java
ls *.class
HelloEnum.class   HelloWorld$HelloInternal.class
HelloInterface.class  HelloWorld.class

Java classes

The classes can be any class, interface and enum.
All java codes should be placed in the classes.
otherwise you will get compile error
class, interface, or enum expected
In fact, enum is a class too, just a syntactic sugar.

Android java: How to display phonetic symbol with correct fonts via WebView ?

First, Download lingoes font file

Android default fonts can not display phonetic symbol.
lingoes.ttf can, please download it.

Second, Put lingoes.ttf to assets/font

assets_font_lingoes.ttf

Last, Add "lingoes" font-family in css files under assets

 @font-face {
    font-family: 'lingoes';
    src:url('file:///android_asset/fonts/lingoes.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
} 

Use "lingoes" as font-family for the phonetic symbol content

Android java : How to load html files in assets via WebView?

Android java : How to load html files in assets via WebView?

The base url for html files under the assets of your app is

"file:///android_asset/"

        WebView wv = new WebView(context);
        wv.getSettings().setJavaScriptEnabled(true);
        wv.loadUrl("file:///android_asset/coca/coca_00001_the.html");

Android java : How to copy/move file from assets to absolute path?

    private void moveAssets(String assets_file_path, String absolutePath) throws IOException {
        File wwwFile = new File(absolutePath);
        if (wwwFile.exists())
            return;
        InputStream is = activity.getAssets().open(assets_file_path);
        byte[] buffer = new byte[is.available()];
        is.read(buffer);
        is.close();
        wwwFile.createNewFile();
        FileOutputStream os = new FileOutputStream(wwwFile);
        os.write(buffer);
        os.close();
    }

TOP 16515 words from Corpus of Contemporary American English



Download for Android
https://play.google.com/store/apps/details?id=com.lengerrong.coca


Android java: How to orientation activity layout automatically ?

Add ~android:screenOrientation="fullSensor"~ to the activity

 AndroidManifest.xml activity android:name=".MainActivity"             android:screenOrientation="fullSensor" 

fixed: embedded-redis: Unable to run on macOS Sonoma

Issue you might see below error while trying to run embedded-redis for your testing on your macOS after you upgrade to Sonoma. java.la...