在Runtime.getRuntime()。exec中有2个可执行文件的空格

我有一个命令,我需要在这些行中使用java运行: C:\path\that has\spaces\plink -arg1 foo -arg2 bar “path/on/remote/machine/iperf -arg3 hello -arg4 world” 当路径没有空格时,此命令工作正常,但是当我有空格时,我似乎无法使其工作。 我尝试过以下操作,运行Java 1.7 String[] a = “C:\path\that has\spaces\plink”, “-arg1 foo”, “-arg2 bar”, “path/on/remote/machine/iperf -arg3 hello -arg4 world” Runtime.getRuntime().exec(a); 以及 String[] a = “C:\path\that has\spaces\plink”, “-arg1 foo”, “-arg2 bar”, “path/on/remote/machine/iperf”, “-arg3 hello”, “-arg4 world” Runtime.getRuntime().exec(a); 但似乎都没有做任何事情。 我有什么问题吗?

这是一个Swing Java 7渲染错误吗?

我做了一个简单的Swing应用程序。 但渲染表现出错误。 我做错了什么或者它是一个错误? 这是一个简单的小型JFrame,带有文本字段,按钮和空列表。 如果我首先水平调整窗口大小然后键入文本字段,按钮突然消失。 这是我的代码: public class App extends JFrame { public App() { JTextField messageFld = new JTextField(); JButton saveBtn = new JButton(“Save”); JPanel inputPanel = new JPanel(new BorderLayout()); inputPanel.add(messageFld, BorderLayout.CENTER); inputPanel.add(saveBtn, BorderLayout.EAST); JList list = new JList(); JPanel panel = new JPanel(new BorderLayout()); panel.add(inputPanel, BorderLayout.NORTH); panel.add(list, BorderLayout.CENTER); this.getContentPane().add(panel); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setTitle(“Test application”); this.pack(); […]

forms参数类型声明中double …和double 之间的区别

我有疑问:这两个声明有什么区别? public static void printMax(double… numbers) { … } public static void printmax(double numbers[]) { … } 是double… numbers与double numbers[]相同?

屏幕右下角的位置

我需要在屏幕上放置JFrame。 但我无法让它们出现在屏幕底部的右侧。 有人可以解释我如何定位它们,如果你能描述如何做,那就太好了。 这是迄今为止的代码。 //Gets the screen size and positions the frame left bottom of the screen GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice defaultScreen = ge.getDefaultScreenDevice(); Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds(); int x = (int)rect.getMinX(); int y = (int)rect.getMaxY()- frame.getHeight(); frame.setLocation(x ,y – 45);

Hibernatevalidation失败时出现意外的UnsupportedOperationException

为什么我在validation失败时从Hibernate获得UnsupportedOperationException? 我希望有一个ConstraintViolationException。 下面是我的DAO。 当它通过validation时,它工作正常。 我正在使用Hibernate和Hibernate Validator 4.我正在使用Websphere 8.0。 我认为WebSphereExtendedJtaPlatform是罪魁祸首,但我不知道为什么。 如果我看一下所谓的WebSphereExtendedJtaPlatform的源代码(跟随源代码的链接),看起来大多数方法只会抛出UnsupportedOperationException。 http://grepcode.com/file/repo1.maven.org/maven2/org.hibernate/hibernate-core/4.0.0.CR1/org/hibernate/service/jta/platform/internal/WebSphereExtendedJtaPlatform.java 这是我的堆栈跟踪: org.hibernate.AssertionFailure HHH000099: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: null id in com.westfieldgrp.beanvalidation.persistence.Car entry (don’t flush the Session after an exception occurs) [11/14/12 16:48:48:785 EST] 00000020 RegisteredSyn […]

在Java中使用.equals方法的正确方法是什么?

我正在和我的CompSci教授交谈,他建议将所有String .equals方法写成: “Hello World”.equals(fooString); 而不是: fooString.equals(“Hello World”); 这两行都编译,但我想知道第一种方式有什么好处? 我总是以后一种方式做到这一点。 这是错的吗? 什么是常见/常规?

点击导航抽屉关闭

我已经实现了导航抽屉,但是我在使其正常运行时遇到了一些麻烦。 当我点击位置1或2时,它不会启动新片段。 MainActivity.java public class MainActivity extends Activity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBarDrawerToggle mDrawerToggle; // nav drawer title private CharSequence mDrawerTitle; // used to store app title private CharSequence mTitle; // slide menu items private String[] navMenuTitles; private TypedArray navMenuIcons; private ArrayList navDrawerItems; private NavDrawerListAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) […]

PDFBox:PDPageContentStream的追加模式行为不端

我正在其中一个PDF页面上绘制图像..当我使用PDPageContentStream stream = new PDPageContentStream(doc, page); 绘制图像,一切正常..见下图。 但是当我使用构造函数PDPageContentStream(doc, page, true, true); 要创建PDPageContentStream并绘制图像,新添加的图像会颠倒倒置。 没有弄到这里出了什么问题.. PS。 我正在使用库PdfBox-Android

如何使用Java Generics避免未经检查的强制转换警告

不知怎的,我的旧问题已经关闭,所以我开了一个新问题: 我正在使用Java Generics从SQL查询中实现通用双向哈希映射。 它应该能够来回映射String,Integer对的任意组合。 它应该像这样使用: String sql = “SELECT string_val, int_val FROM map_table”; PickMap pm1 = new PickMap(sql); String key1 = “seven”; Integer value1 = pm1.getLeft2Right(key1); Integer key2 = 7; String value2 = pm1.getRightToLeft(key2); 当然应该可以创建一个pm(整数,整数)等等…… 我对Pick Map的实现看起来像这样(没有getter …): public class PickMap { private final HashMap left2Right = new HashMap(); private final HashMap right2Left = new […]

如何在java中的目录中对文件进行排序?

这是我的代码,它的工作原理! 但我希望能够根据名称,大小,修改日期等对文件列表进行排序 import java.io.File; import org.apache.commons.io.FileUtils; public class StartingPoint { public static void main(String[] args) { File file = new File( “/home/t/lectures”); File[] files = file.listFiles(); for (File f : files) { System.out.println(“File : ” + f.getName() + ” [” + FileUtils.byteCountToDisplaySize(f.length()) + “]”); } } }