我正在使用ProcessBuilder来执行bash命令:
import java.io.IOException;
public class Main {
public static void main(String[] args) {
try {
Process pb = new ProcessBuilder("gedit").start();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
但我想做这样的事情:
Process pb = new ProcessBuilder("sudo", "gedit").start();
Run Code Online (Sandbox Code Playgroud)
如何将超级用户密码传递给bash?
("gksudo", "gedit") 不会这样做,因为它已经被删除,因为Ubuntu 13.04并且我需要使用默认命令可用.
编辑
gksudo在最后一次更新时回到了Ubuntu 13.04.
我正在使用本网站的教程- "修正时间步"部分.
这是代码 - http://pastebin.com/QaHgcLaR
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class GameLoopTest extends JFrame implements ActionListener
{
private GamePanel gamePanel = new GamePanel();
private JButton startButton = new JButton("Start");
private JButton quitButton = new JButton("Quit");
private JButton pauseButton = new JButton("Pause");
private boolean running = false;
private boolean paused = false;
private int fps = 60;
private int frameCount = 0;
public GameLoopTest()
{
super("Fixed Timestep Game Loop Test");
Container cp = getContentPane();
cp.setLayout(new BorderLayout());
JPanel …Run Code Online (Sandbox Code Playgroud) 我有简单的程序:
#include <stdio.h>
int a = 5;
int
main(void)
{
while(1)
{
int i;
sleep(1);
printf("%p %i\n", &a, a);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出(Ubuntu x64):
0x601048 5
0x601048 5
0x601048 5
0x601048 5
Run Code Online (Sandbox Code Playgroud)
我正在学习C中的指针,我已经知道你可以用来memcpy在过程的虚拟内存中的任何地方(几乎)编写数据.但是,是否可以通过使用另一个应用程序(当然使用自己的虚拟内存)来修改int a放置在0x601048地址的值?这该怎么做?我只对C的解决方案感兴趣