如何在windows linux命令上运行使用linux下面的命令

中国领先的IT技术网站
51CTO旗下网站
如何安装和使用Wine,以便在Linux上运行Windows应用程序?
Wine的功能是让Windows应用程序可以在Linux平台上运行。它并不完美,支持的应用程序也很有限。如果你想要记事本(Notepad)、计算器(Calculator)和纸牌游戏(Solitaire),你就随时可以使用了。迄今为止,有数千款全面得到支持的应用程序如今可以在Wine上运行,而且这份列表越来越长。
作者:布加迪编译来源:51CTO| 10:04
1&Elementary OSFreyaNotepad++
902000LinuxWindowsLinuxWineWine Is Not an EmulatorWindowsWine
WineWindowsLinuxNotepadCalculatorSolitaire
WineLinuxWinehttps://appdb.winehq.orgWine
WineWineWineWindows
&Elementary OSFreyaWine
UbuntuSoftware CenterWineWineGUIWindowsGUI
1. Applications
2. software
3. Software & Updates
4. Other Software
6APTppa:ubuntu-wine/ppa2
7. Add Source
9. Authenticate
11. Reload
12. Software Center
14. WineInstall
WineWindows
Notepad++Filehippo/zh/download_notepadNotepad++DownloadsNotepad.exeOpen in Wine Windows Program LoaderWine Windows3
3WineNotepad++ .msi
~/.wineWineWindowsNotepad++
Next4LinuxFolder
LinuxWindowsC~/.winedrive_c
&Program Files
Choose Components5Create Shortcut on Desktop
5Notepad++
FinishRun NotepadFinishNotepad++1
Program FilesNotepad++notepad++.exeOpen in Wine Windows Program LoaderWine WindowsNotepad++
Notepad++WineWineWine
【编辑推荐】
【责任编辑: TEL:(010)】
大家都在看猜你喜欢
头条头条热点头条热点
24H热文一周话题本月最赞
讲师:30264人学习过
讲师:157478人学习过
讲师:82904人学习过
精选博文论坛热帖下载排行
作为深受编程人员爱戴和尊敬的编程专家,微软.NET开发团队的顾问,本书作者Jeffrey Richter针对开发各种应用程序(如Web Form、Windows For...
订阅51CTO邮刊内容字号:
段落设置:
字体设置:
精准搜索请尝试:
Win10使用进阶:一周年更新14316如何开启Linux Bash命令行
来源:作者:玄隐责编:玄隐
4月7日凌晨,微软推送了最新的Win10一周年更新预览版14316,这也是开发者会后首个系统版本,在该版本中包含了大部分已宣布内容,其中就包括重要的原生支持Linux &Bash命令行支持。用户现在即使不使用Linux系统或Mac电脑就可以在上使用Bash,那么Win10系统上如何开启Bash命令行功能呢?•&首先将Win10系统升级到最新的Build 14316,然后到系统设置——更新和安全——针对开发人员——选择开发者模式。•&然后系统搜索“程序和功能”,选择“开启或关闭Windows功能”,开启Windows Subsystem for Linux (Beta),并重启系统。安装Bash,需要开启命令行模式,然后输入“bash”,即可使用。相关阅读:《》《》《》《》《》《》关注,锁定之家()
软媒旗下软件:
IT之家,软媒旗下科技门户网站 - 爱科技,爱这里。
Copyright (C) , All Rights Reserved.java中运行外部命令(比如windows下的dos命令、linux下的shell命令)的方法:
Process proc = Runtime.getRuntime().exec(cmdstring);
其中cmdstring就是需要运行的外部命令。
注意:运行windows下的dos命令,不能直接exec(cmd),可以这样来调用:
cmdstring = "command.exe /c dir"; // 其中/c表示运行命令后关闭cmd窗口
Runtime.getRuntime().exec(cmdstring);
也可以将命令写到一个脚本文件中,然后执行该脚本文件。
如果命令有多个参数,可以用如下方法:
// Execute a command without arguments
String command =&"ls";
Process child = Runtime.getRuntime().exec(command);
// Execute a command with an argument
command =&"ls -al
child = Runtime.getRuntime().exec(command);
&&& } catch
(IOException e) {
&&&&&&&&&&
//错误处理操作
“If an argument contain spaces, it is necessary to use the overload
that requires the command and its arguments to be supplied in an
如果参数中有空格或特殊字符的,可以使用exec的重载形式,传入一个字符串的数组:
// Execute a command with an argument that contains a space
String[] commands = new String[]{"grep", "hello world", "/tmp/f.txt"};
commands = new String[]{"grep", "hello world", "c:\\Documents and Settings\\f.txt"};
Process child = Runtime.getRuntime().exec(commands);
} catch (IOException e) {
接下来,我们看一下java调用linux shell脚本的方法:
首先,我们需要增加用户对该脚本的执行权限,即
String cmdstring = "chmod a+x test.sh";
proc = Runtime.getRuntime().exec(cmdstring);
proc.waitFor(); //阻塞,直到上述命令执行完
cmdstring = "bash test.sh"; //这里也可以是ksh等
proc = Runtime.getRuntime().exec(cmdstring);
//注意下面的操作
string ls_1;
BufferedReader
bufferedReader
BufferedReader(
InputStreamReader(proc.getInputStream());
(ls_1=bufferedReader.readLine())
bufferedReader.close();
proc.waitFor();
为什么要有上面那段操作呢?
原因是:可执行程序的输出可能会比较多,而运行窗口的输出缓冲区有限,会造成waitFor一直阻塞。
解决的办法是,利用Java提供的Process类提供的getInputStream,getErrorStream方法
让Java虚拟机截获被调用程序的标准输出、错误输出,在waitfor()命令之前读掉输出缓冲区中的内容。
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。我要分享到:
系统教程栏目
win10系统教程排行
12345678910
大家都在使用}

我要回帖

更多关于 windows linux 命令行 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信