In order to obtain the national flag, companies must be headquartered in Japan and their partners (unlimited partnership) and two thirds or more of their  managing directors must be nationals. Without the national flag, vessels may not engage in cabotage.
"Article 1 The following ships shall be designated as Japanese ships
(i) Ships owned by Japanese government agencies or public offices
(ii) Ships owned by Japanese citizens
(iii) Ships owned by a company incorporated under the laws of Japan, at least two-thirds of whose representatives and officers executing business belong to Japanese nationals
(iv) A juridical person other than the juridical person listed in the preceding item, which was established in accordance with Japanese laws and regulations, and all of its representatives belong to Japanese nationals.
[...]
Article 3 Vessels which are not Japanese vessels may call at non-open ports or carry goods or passengers between Japanese ports; provided, however, that this shall not apply if otherwise provided for by law or treaty, if they avoid maritime accidents or capture, or if they obtain a patent from the Minister of Land, Infrastructure, Transport and Tourism.[...]" (Ship Act (No. 46 of 1899), last amended June 13, 2014, Articles 1 and 3 [google translation])
Ship Act (No. 46 of 1899),  last amended April 1, 2019, Articles 1 and 3
[<a href="https://elaws.e-gov.go.jp/document?lawid=132AC0000000046">Act</a>],[<a href="https://www.oecd.org/daf/inv/investment-policy/NTItransparencyENG.pdf">Other</a>]