I'm trying to open an xterm terminal in Java, and run a Java file in it. Here's the Java code that is opening up the terminal:
Process p2 = new ProcessBuilder("xterm", "-hold", "-e", "java", "/home/harry/main.class").start();
xterm opens fine, but it's saying that it can't find the main class home.harry.main.class
. I'm using slashes, but they're being changed to dots. What am I doing wrong?
The mention of xterm
is misleading. The question (agreeing with @elliott-frisch and @user2533521 ) is how to run a Java class on the command-line. The full pathname and classfile name are two aspects which have to be separated.
Not quite a duplicate, these links can give some insight:
That is (referring to the documentation ):
-cp
option (see Setting the class path ).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.