[英]How do I make a new main class? There is already one made but its not its own .java file and currently does not work
public static void main(final String[] args) {
// Detect if we are running on mac
if (isMac()) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("dock.name", "LoboBrowser");
}
// Checking for stack allows us to call AccessController.doPrivileged()
// which in turn allows us to reduce the permissions on Uno codesource
final int stackDepth = Thread.currentThread().getStackTrace().length;
if (stackDepth > 11) {
System.err.println("Stack depth (" + stackDepth + ") is too deep! Quitting as a safety precaution");
Thread.dumpStack();
System.exit(1);
} else {
privilegedLaunch(args);
}
}
private static void launch(final String[] args) {
try {
final SSLSocketFactory socketFactory = TrustManager.makeSSLSocketFactory(ReuseManager.class.getResourceAsStream("/trustStore.certs"));
ReuseManager.getInstance().launch(args, socketFactory);
} catch (final Exception err) {
final StringWriter swriter = new StringWriter();
final PrintWriter writer = new PrintWriter(swriter);
err.printStackTrace(writer);
writer.flush();
JOptionPane.showMessageDialog(new JFrame(),
"An unexpected error occurred during application startup:\r\n" + swriter.toString(),
"ERROR", JOptionPane.ERROR_MESSAGE);
System.err.println(swriter.toString());
System.exit(1);
}
}
我相信您必须将主要方法放入 class 中,如此处所述http://tutorials.jenkov.com/java/main-method.html 。 我知道在 net beans 你可以告诉它要尝试运行什么 class 我认为右键单击运行然后选择要运行的文件,如果设置正确,它将运行该文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.