如何启动具有更多内存的Java小程序?

对于大型Java应用程序,默认的64 MB最大堆内存可能很小。 是否有任何applet参数可以为签名的applet增加此值? 对于Java程序,这是一个简单的命令行参数,但这对于浏览器中的applet是如何工作的。

IntelliJ gradle添加模块依赖

使用IntelliJ 2016.2。 使用Gradle 2.14.1 我有2个项目,每个项目都有自己的build.gradle文件和单独的目录结构: myLib (meant to be jarred and used by others) – build.gradle – settings.gradle – src/main/java/… sandbox (spring boot web app) – build.gradle – settings.gradle – src/main/java/… – src/main/resources/… 希望你能得到这张照片。 在IntelliJ中,我有以下模块结构,在同一级别(没有子项目): – myLib – sandbox 简单的请求…我想在sandbox应用程序中使用myLib 。 我想在同一个项目中同时开发这两个模块。 我已经尝试在IntelliJ中为myLib添加模板依赖项到sandbox 。 没有骰子。 我试过添加一个jar参考,没有骰子。 我相信我需要在build.gradle文件中添加一个依赖项,但无法弄清楚如何。 我已经尝试过compile files ”等等。没有骰子。

Java字符串右对齐

我有一些这些数字 61672 8414449 264957 我使用像这样的DecimalFormat对象 DecimalFormat formatter = new DecimalFormat(“###,### bytes”); 得到这些结果 61,672 bytes 8,414,449 bytes 264,957 bytes 但我需要将结果与以下内容对齐 61,672 bytes 8,414,449 bytes 264,957 bytes 您的帮助已经受到赞赏。

在java中设置方法的运行时间限制

我有一个返回String的方法,是否有可能在某个时间阈值后,该方法返回一些特定的字符串?

Checkstyle“方法未设计为扩展”错误被错误地发出?

我正在使用Checkstyle并且收到有关此方法的错误: public final String getAdmitCodeStatus() { return admitCodeStatus; } 这是我得到的错误: 方法’getAdmitCodeStatus’不是为扩展而设计的 – 需要是abstract,final或empty。 该方法如何不符合要求? 有什么我做错了,Checkstyle会对我这个方法咆哮吗?

避免jvm热身

如果我正在设计排序算法测试,我可以这样做以避免JVM热身吗? 谢谢! double count = 0; double start, end; for(int r = 0; r < warmup; r++) { // do test } for(int t = 0; t < runs; t++){ start = System.nanoTime(); // do test end = System.nanoTime(); count += start – end; } double avg = count/avg

如何使用java获取xml节点的属性值

我有一个看起来像这样的xml: { …..} 在这里,我想检索“源类型”的值,其中类型s属性。 我试过这样,但它不起作用: DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder builder = domFactory.newDocumentBuilder(); Document dDoc = builder.parse(“D:/workspace1/ereader/src/main/webapp/configurations/config.xml”); System.out.println(dDoc); XPath xPath = XPathFactory.newInstance().newXPath(); Node node = (Node) xPath.evaluate(“//xml/source/@type/text()”, dDoc, XPathConstants.NODE); System.out.println(node); } catch (Exception e) { e.printStackTrace(); 我也试过这个: DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); InputSource is = new InputSource(new StringReader(“config.xml”)); Document doc […]

什么是正确的Java main()方法参数语法?

这些方法之间是否存在function差异? public static void main(String[] args) { } public static void main(String args[]) { } 编辑(从其他贡献者添加此语法): public static void main(String… args) { }

Java – 选择排序算法

我对选择排序有一些疑问。我有点困惑。 int [] arr = {5,4,3,2,1}; // This is my array int min = 0; for(int i = 0;i<arr.length;i++) { //Assume first element is min min = i;//Selection sort algorithm says that find the minimum in the // array, but first element is not minimum.What's point here? for(int j = i + 1;j<arr.length;j++) { int […]

JavaFx:在应用程序执行不同方法时,与消息异步更新UI标签

我正在尝试使用应用程序的各种状态消息异步更新JavaFx GUI中的标签。 例如 我的Application中的按钮“更新”调用控制器中的方法updateSettings()。 现在我尝试以下列方式更新UI上的标签。 @FXML private void updateSettings() { label.text(“message1”); //some action lable.text(“action done”); label.text(“calling method.. wait for some time”) // call to time consuming method – timeConsumingMethod(); label.text label.text(“operation completely successfully”); } private void timeConsumingMethod() { label.text(“message2”); //some actions label.text(“message3”); //more time consuming actions label.text(“time consuming method is done with success”); } 我希望在流程执行时这些消息应该显示在标签中,以向用户显示应用程序中正在进行的各种活动。 […]