I tried to compile the java file with javac at the command prompt, but I got the following error:
C:\Users\rqwqk\Desktop\pleiades\workspace\konpairuzikken\src>java wrqrqrqr
Error: Main method not found in class wrqrqr.Define the main method as follows:
public static void main (String[]args)
Alternatively, the JavaFX application class must extend `javafx.application.Application`
The contents of wrqrqr.java are as follows and the running environment is Windows 7 (x64).We are looking for solutions.
public class wrqrqr{
/**
* @paramargs
*/
public static class hello world {
public static void main(String[]args) {
// TODO AUTOMATICALLY GENERATED METHOD STUB
intx;
x = 5;
System.out.println(x);
}
}
}
The reason is that public static void main(String[]args)
is not defined in the wrqrqr
class.
If you modify the source code as follows and run it after compilation, you will see 5
on the screen.
source code:
public class wrqrqr{
/**
* @paramargs
*/
public static void main(String[]args) {
// TODO AUTOMATICALLY GENERATED METHOD STUB
intx;
x = 5;
System.out.println(x);
}
}
commands:
javac-encoding UTF-8wrqrqr.java
java wrqrqr
5
By the way:
If the source code is UTF-8 with BOM (byte order mark), I think there will be an error when compiling.
https://stackoverflow.com/a/28043356/4366193
Remove BOMs from tools, editors, etc.
For PowerShell, you can delete the BOM using the following command:
[System.IO.File]::WriteAllText(Get-Location).Path+'\wrqrqr.java', (Get-Content.\wrqrqr.java-Encoding UTF8-Raw))
javafx.application.application
is irrelevant.
All you have to do is clear the public static class hello world {
and corresponding closed brackets.
java wrqrqr$helloworld
or
java wrqrqr\$helloworld
© 2024 OneMinuteCode. All rights reserved.