は、それらのどれも働かない今、私はSystem.getPropertyを使用してJavaファイルクラス名を取得する方法
class main {
public static void main(String [] args) throws Exception
{
String className = System.getProperty(DevelopmentFeeCalculator.class.getName());
String
className1 = System.getProperty("user.dir.DevelopmentFeeCalculator.class.getName()");
String
className2 = System.getProperty("DevelopmentFeeCalculator.class.getName()");
}
}
このファイルのクラス名を取得したい、私はプロジェクトフォルダ内DevelopmentFeeCalculatorという名前のファイルがあるとします。あなたはあなただけ使用することを望む場合
https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
:まあはSystem.getPropertyはそのporpuseここ
のためではありません
あなたは正確にあなたが何をする必要がありますどのような –
を使用しますが、私のインストラクターははSystem.getPropertyを(使用するように私に言っていません?クラス名が必要な場合は、システムプロパティを使用する必要はありません。 –
)、 'System.getProperty'を必要とするだけで' DevelopmentFeeCalculator.class.getName() ' –