eclipse中如何让cveigendecompositee与shell处于同一级

java eclipse中如何实现点击主窗口sShell中的按钮打开另外一个子窗口sShell_百度知道
java eclipse中如何实现点击主窗口sShell中的按钮打开另外一个子窗口sShell
import java.awt.*;import java.awt.event.*;import javax.swing.AbstractBimport javax.swing.JBimport javax.swing.JFimport javax.swing.JLimport javax.swing.JPimport javax.swing.JTextFpublic class button extends JFrame{public button(){ JButton button=new JButton(&查找&); setLayout(new FlowLayout()); add(button);button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
selectinterface sl = new selectinterface();
sl.setVisible(true);
sl.pack();
}public static void main(String[] args) {
// TODO Auto-generated method stub
button frame=new button();
frame.setTitle(&按钮&);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,600);
frame.setVisible(true); } }class selectinterface extends JFrame{ public selectinterface(){
JPanel p1=new JPanel();
p1.setLayout(new GridLayout(9,2,5,5));
p1.add(new JLabel(&编号&));
p1.add(new JTextField(6));
p1.add(new JLabel(&姓名&));
p1.add(new JTextField(8));
p1.add(new JLabel(&性别&));
p1.add(new JTextField(1));
p1.add(new JLabel(&年龄&));
p1.add(new JTextField(2));
p1.add(new JLabel(&职位&));
p1.add(new JTextField(20));
p1.add(new JLabel(&学历&));
p1.add(new JTextField(4));
p1.add(new JLabel(&学位&));
p1.add(new JTextField(4));
p1.add(new JLabel(&工龄&));
p1.add(new JTextField(2));
p1.add(new JLabel(&工资等级&));
p1.add(new JTextField(2));
JPanel p2=new JPanel();
p2.add(new JButton(&确定&));
p2.add(new JButton(&取消&));
setLayout(new GridLayout(2,1,0,100));
其他类似问题
为您推荐:
先用eclipse的界面设计器设计好你要用的两个界面然后在主界面的一个button上添加一个单击事件在事件的处理代码中产生一个界面2的类并且将该对象的可视化属性设置为可见即可
eclipse的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁tianya23 的BLOG
用户名:tianya23
文章数:864
评论数:63
访问量:1645105
注册日期:
阅读量:5863
阅读量:12276
阅读量:298255
阅读量:1018740
51CTO推荐博文
&Eclipse使用总结
1、Eclipse中出现无法找到Maven包
&& &症状:出现org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER, 且出现无法找到Maven的依赖的问题
&&解决方案:Build Path -》 Java Build Path -》Libraries -》Add Library -》Maven Managed Dependences -》点击Next -》点击&Maven Project settings& , 在&Active Maven Profiles (comma separated)&中添加&Maven Dependencies&确认即可。此时会在Classpath 的Libraries的标签栏下面看到添加的&Maven Dependencies&。
2、在maven中可能存在如下的错误
在eclipse中表现为无法找到依赖的jar包,而&Maven Dependencies中却能找到相应的jar包
Failure executing javac, but could not parse the error:
错误:读取 C:\Documents and Settings\keju.wangkj\.m2\repository\com\sun\jdmk\jmxtools\1.2.1\jmxtools
-1.2.1.jar 时出错;error in opening zip file
错误:读取 C:\Documents and Settings\keju.wangkj\.m2\repository\com\sun\jmx\jmxri\1.2.1\jmxri-1.2.1.
jar 时出错;error in opening zip file
解决方案:由于maven下载了空壳的jar包在仓库中,只有1k左右,删除之后让maven重新下载
ctrl+shift+/:注释【先选中需要注释的行】, 与ctrl+/的方式有区别
ctrl+shift+\:取消注释
ctrl+shift+g:哪些在调用此方法
4、开发Java Web程序是Jar包的查看
Navigator:可以看到Jar包
Package Explorer:正常开发
5、Eclipse中的XML文件标签自动提示
&& 在xml文件中引入spring的相关的命名空间之类的文件中,有时出现不能自动提示新的标签的情况。
解决办法:
&& (1)先关闭xml文件再打开
&& (2)引入&xsd&的时,结尾的&&&&需要紧随xsd之后,不要换行
6、Eclipse中的Database视图模块出现不上数据库的问题
修改eclipse.ini中修改-Duser.language=zh即可
7、eclipse中设置文件的默认打开模式
Window -& Preferences -&General -& Editors -& File Associations中设置各种文件类型默认使用什么编辑器打开,则可以使用很多自动提示功能
&8、受限的类访问
问题:&Access&restriction: Class is not accessible due to&restriction&on required library&; error message may be shown while developing&Java&projects in Eclipse IDE. Error message is self-explanatory, some classes can not be loaded into the project sincerestriction&rules are being imposed on those classes.
解决方案:
This error message can be removed by changing a setting inside Eclipse IDE. Open up the dialog box shown below, using any of the following paths.
Windows -& Preferences -&&Java&-& Compiler -& Errors/Warnings -& Deprecated and restricted API -& Forbidden reference(access rules), 将error修改为warning
(Project) Properties -&&Java&Compiler -& Errors/Warnings
Locate the &Forbidden reference (access&rules)& option under &Deprecated and restricted API& section in the dialog box. This option decides how to handle&accessrules defined inside Eclipse. By default it is set to &Error& which causes Eclipse to complain about references to any restricted classes. Choosing any other option (Warning or Ignore) will remove these error messages.
&Warning& or &Ignore& options will only hide the potential issue in the project, by allowing the project to use any classes ignoring predefined&access&rules. To completely resolve this issue, analyze the project and located the use of restricted classes and take necessary actions (either remove those references or&accessrules).
&9、为eclipse中的Deprecated方法添加警告标示,方便识别
Windows -& Preferences -&&Java&-& Compiler -& Errors/Warnings -& Deprecated and restricted API -&Deprecated API,选择上下面的2个Combo Box(组合框),&single use 。。&和&Single overriding。。&
&10、修改eclipse的jvm大小
在eclipse根目录下面的eclipse.ini文件中进行修改,进一步细节参考如下链接
&11、Eclipse中的classpath
Java Build Path -& Source 下面, 有关于编译之后生成的文件的目录结构的详细说明
提示错误: JVM&& terminated. Exit&& code=-1。&
在网上找了一下,有人说是JAVA环境配置的问题,我想这不可能,因为以前一直用的好好的。有人说是JVM的问题,这个我刚刚换了一个,也不是这个问题,后来看来有人说是:eclipse.ini中内存设置过大的问题,虽然我不以为然,还是试了一下,以前我修改过内存设置,一直都好好的,之前eclipse.ini的配置如下:&
-showsplash&
com.genuitec.myeclipse.product&
--launcher.XXMaxPermSize&
-Duser.language=en&
-XX:PermSize=256M&
-XX:MaxPermSize=512M&
现在修改了一下,-Xms256m改成-Xms128m,把Xmx512m& 改为 Xmx256m,结果还真的好了,没想到居然是这样的小问题引起来的。&
13、设置maven调试端口
set MAVEN_OPTS=-Xdebug -Xnoagent -piler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
调试的过程中,在eclipse的左下角处将&Expressions&调出来,可以观察自己想看的操作,比较有用。
14、Eclipse 中 drop to frame 的调试技巧
前些天和同事交流调试技巧时,知道了 Eclipse debug 时有个 drop to frame 的技巧。这是我以前不知道的,自己又查了一下这个功能的含义。官方的解释是:
Select the&Drop to Frame&command [&650) this.width=650;" alt="Drop" to="" style="line-height: 20 border-top-width: 0 border-right-width: 0 border-bottom-width: 0 border-left-width: 0 border-style: border-color: max-width: 100%; " src="http://help.eclipse.org/galileo/topic/org.eclipse.jdt.doc.user/images/org.eclipse.debug.ui/elcl16/drop_to_frame.png" />&] to re-enter the selected stack frame in the&Debug View.
Note this command is only available if the current VM supports drop to frame and the selected stackframe is not the top frame or a frame in a native method.
就是说,这个功能可以重新跳到当前方法的开始处重新执行,并且所有上下文变量的值也回到那个时候。不一定是当前方法,可以点击当前调用栈中的任何一个frame跳到那里(除了最开始的那个frame)。主要用途是所有变量状态快速恢复到方法开始时候的样子重新执行一遍,即可以一遍又一遍地在那个你关注的上下文中进行多次调试(结合改变变量值等其它功能),而不用重来一遍调试到哪里了。当然,原来执行过程中产生的副作用是不可逆的(比如你往数据库中插入了一条记录)。
这里也说了如何使用这个功能:http://www.javalobby.org/forums/thread.jspa?threadID=15271&tstart=0
其实这个功能早就有了,就是一般人不知道或很少使用。
Display&视图允许您以剪切类型的方式处理活动代码(参见图 8)。要处理一个变量,在&Display&视图中输入变量名即可,视图会提示您一个熟悉的内容助手。ctrl+shift+d即可查看内容,更多内容参考:
&System.identityHashCode(this):查看对象的唯一id号
16、Java 远程Debug官方指导文档
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
17、远程调试tomcat中的程序
第一种是采用Eclipse中的远程Debug功能&
修改Tomcat的bin\catalina.bat,在里面加入set & JAVA_OPTS=-Xdebug & -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7777 &&
然后在Eclipse中选择debug,新建&Remote & Java & Application,在port上写入7777,然后再启动Tomcat,打上断点就OK了。&
第二种方法是安装Eclipse的Tomcat插件,网上很多地方可以下载,在Eclipse中使用Tomcat插件启动Tomcat,就可以直接打断点Debug了&&
18、统计工程或文件的代码行数
使用Eclipse可以方便的统计工程或文件的代码行数。
方法如下:
1.在菜单栏点击Search,然后点击File...
2.选中正则表达式(Regular expression),并在搜索文本框输入\n
3.在文件名中输入*或*.java
4.在范围里选中Enclosing projects
5.在Search窗口就会显示出项目或文件的代码行数&
或者使用小插件:
19、清除eclipse中的SVN记录,修改用户名和密码
删除掉C:\Documents and Settings\用户名\Application Data\Subversion\auth\svn.simple文件夹下的文件即可.&&&
再次访问时,会弹出要求输入用户名和密码, Application Data是一个隐藏的文件夹.&
20、找不到src/main/java等
修改pom关系,扩展了子模块的情况下,可能在eclipse中报找不到src/main/java、src/main/resources等的情况。 是由于mvn eclipse:clean插件没有清理干净造成的。细节原因: 将&packaging&jar&/packaging&修改为&packaging&pom&/packaging&, 此时mvn eclipse:clean不会清理根下面的.classpath和.project文件。
解决方案:删除工程,svn出全新的内容进行mvn eclipse:eclipse或者手动删除根下面的.classpath和.project2个文件。
21、同一设置工程下面各模块的字符集
Window-& Preference-&General-&Workspace,右侧的Text File encoding设置为UTF-8,则以后建立的工程及各模块默认为UTF-8了。&
22、Eclipse中的Maven Dependencies消失了
使用m2e,先Disable Maven Management,再 Enable Maven Management即可找回消失的Maven Dependencies
23、删除了的workspace
删除Eclipse的workspace,
找到 eclipse\configuration\.settings\org.eclipse.ui.ide.prefs 文件
用记事本打开,找到
RECENT_WORKSPACES=D\:\\workspaces\\workspace7\nC\:\\Documents and Settings\\keju.wangkj\\workspace
将不用的workspace目录删掉就可以了
24、查看eclipse的版本
进入到eclipse安装目录下,有一个.eclipseproduct文件,用记事本打开,就可以知道版本了。
25、eclipse启动时,failed to create the java virtual machine
-startup&plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v0.jar&&plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.2.R36x_v&-product&org.eclipse.epp.package.rcp.product&&openFile&&256M&-showsplash&org.eclipse.platform&&256m&&openFile&-vmargs&-Dosgi.requiredJavaVersion=1.5&-Xms40m&-Xmx512m&
&将上面的替换为:
-startup&plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v0.jar&&plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.2.R36x_v&-product&org.eclipse.epp.package.rcp.product&&openFile&&128M&-showsplash&org.eclipse.platform&&128m&&openFile&-vmargs&-Dosgi.requiredJavaVersion=1.6&-Xms40m&-Xmx256m&
26、开发和运行eclipse plugin的eclipse ide
可以使用的ide有: eclipse-rcp-helios-SR2-win32
不可以使用的ide有:
27、启动eclipse时,building workspace卡住
1. 取消 project -& build automatically 的选择&
3. 删掉多余项目&
4。 再将项目拷贝进来&
28、调试中,条件断点的设置
即满足条件时在断点暂停下来,否则直接pass。【注意】设置条件的时候,需要在获取到结果的下面设置断点,并进行设置条件,否则不生效(因为断点的意思是:在接触到行就暂停,即最开始就暂停,还没到判断条件)。
&Hit count:可以设置第几次满足条件的时候在断点处暂停下来,在调试循环中特别有用。
以上方式经过本人在eclipse中测试通过,可放心使用。
例子:判断条件为fileName当等于&run/intl_rfq/buyRequest/buyRequest_run.js&时停在断点:fileName.endsWith(&run/intl_rfq/buyRequest/buyRequest_run.js&)
29、搜索时,出现problems encountered during search
点击详细信息时显示:Resource is out of sync with the file system
解决方案:&Window-&Preferences menu, then in the Preferences dialog box, select General & Workspace.&Check the &Refresh automatically& box.
30、java.lang.NoClassDefFoundError: org.junit.runner.Runner
java.lang.NoClassDefFoundError:&org.junit.runner.Runner&&&&&at&org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)&&&&&at&org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)&&&&&at&org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.&init&(JUnit4TestReference.java:32)&&&&&at&org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.&init&(JUnit4TestClassReference.java:25)&&&&&at&org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)&&&&&at&org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)&&&&&at&org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)&&&&&at&org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)&&&&&at&org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)&&&&&at&org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)&
java.lang.NoClassDefFoundError: org/junit/runner/notification/RunListener&
这个异常是一个项目中存在多个Junit的jar,你需要检查当前项目下是否有两个junit.&
[一般情况下只有一个]&
还有一个重要的地方是,当前项目所依赖的项目中是否也存在Junit,如果依赖的项目Junit版本和当前项目的Junit版本不一致,那么恭喜你,你悲剧了,会发生如上错误。&
31、打开过个Eclipse工作空间后,在切换工作空间时常常无法区分是那个工作空间
可以通过在eclipse启动是加上 -showlocation 这个参数显示工作空间信息
如:eclipse.exe -showlocation
标题栏上会显示当前工作空间信息。这时我们可以区分正在使用的是哪一个Eclipse
31、干掉已经完成的todo
在eclipse中,ide会产生大量的// TODO,用于提醒程序员那些未完成的事情,通过Tasks视图可以查看到那些未完成的内容。代码已经完成,请删除之,这个写代码的好习惯。
32、定位行、列
行:ctrl+l,或者在编辑框的左侧有:show line numbers
列:暂没有查到快捷键,但eclipse的底部,使用java editor打开时,在smart insert的右边会现在当前光标所在的行和列&
33、Please enter the secure storage password ???
在unbuntu下面,启动eclipse的时候总是报:Please enter the secure storage password ???
解决方案:&delete the .eclipse folder that is inside your home directory. 删除或重命名.eclipse,再重启则ok
34、文本字体设置
Windows-& Preferences-&General-&Appearance-&Basic-&Text Font-&Edit-&设置如下:
字体:Courier New
字形:常规
35、导出eclipse所有的配置,方便以后的配置
Eclipse的 File -& Export(导出),在窗口中展开 General(常规) -& Perferences(首选项)--&Export all(全部导出)然后点击 NEXT。然后点击&Browse(浏览)&选择任意的一个路径,保存配置文件,然后点击&Finish&。
&选择File-&export-&preferences.里面就有具体的到处选项了,到了其他的eclipse里选择import就可以了,顺序是对应的
36、eclipse的svn plugin的图标消失
在网上找了半天,没有找到正确的解决方案。直接拷贝其他的eclipse启动,导入相应的config进行还原。
总结:不要在环境上面花太多的时间,直接拷贝导入搞定。
了这篇文章
类别:┆阅读(0)┆评论(0)
16:50:03 13:39:33请问在eclipse里面怎么使用python交互式的shell_百度知道
请问在eclipse里面怎么使用python交互式的shell
怎么设置能帮下忙么。。。多谢
提问者采纳
在pydev的console view的工具栏里有一个open console,然后选pydev console,然后可以选择你需要那种interpreter。
提问者评价
其他类似问题
为您推荐:
您可能关注的推广
python的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁eclipse如何写.gdbinit,如何使用gdb shell命令 -Java- TryCatch
>> Content
eclipse如何写.gdbinit,如何使用gdb shell命令
大家好!!我的环境是ubuntu&9.10&gnome.我使用CDT&eclipse+gdb调试程序,在debugger中设置默认不加载所有库调试信息,希望在开始调试后加载特定库调试信息。我想到了使用gdb的.gdbinit文件。但是我写了几个命令,都没有反应,不知道是哪里的问题。我把.gdbinit文件放在可执行程序下面.另外,gdb的shell命令也不好使了。比如shell&ls,没有任何反应。谁能介绍一篇讲eclipse&gdb&.gdbinit的文章给我。或者指出我的问题所在。谢谢
------Solutions------
http://blog.chinaunix.net/u3/111274/showart_2162256.html
------Solutions------
非常感谢!!.gdbinit文件已经被eclipse使用了。原来没有效果的原因是eclipse设置的debugger是gdb&Debugger,我换成了gdb/mi就可以了。还有个问题。我跟踪了eclipse中gdb初始化的过程,发现eclipse会在load&file后调用.gdbinit,我已经成功通过.gdbinit设置main断点,打印一些消息。但是因为.gdbinit被调用时,程序还没有run,所以无法load&library.我原来在命令行下的gdb通过break&&command&1\n&sharedlibrary&.......\n&end来加载库。现在看来,这断点被eclipse控制,无法使用了。不知道怎么可以做到在.gdbinit中自动加载library。我的目标是不加载所有库,只加载特定库。谢谢
------Solutions------
通过在.gdbinit中加入sharedlibrary确实可以加载指定的库,在试验工程中成功了,但是在我的工程中确没有成功,郁闷。方法是:break&maincommand&1sharedlibrary&/path/to/library/.soend可以确定该脚本已经被执行了,但是不知道为什么库没有加载成功。通过程序暂停,在gdb&console中手动加载可以成功。可能是执行脚本的时候,gdb还没有加载完成?
------Solutions------利用shell命令实现Eeclipse对Android的远程调试 - 简书
下载简书移动应用
写了19001字,被10人关注,获得了15个喜欢
利用shell命令实现Eeclipse对Android的远程调试
这篇文章主要讲如何自己来做一个apk实现远程调试,也就是说我们先自己写一个apk来控制是否启用远程调试的功能,然后通过这个apk来启用远程调试,接着基于远程adb的方式来调试以后的程序。听起来真TM绕口。没关系,跟着看就行了。实现这个目标分为3步。
1.了解shell命令2.如何在android上执行shell3.pc端的命令
1.了解shell命令
好吧,这个逼格的东西并不需要你多么的了解,我们只需要知道几条基本的命令。设置adb的调试端口,当端口&-1的时候,adb是wifi调试,我们默认的一般将端口设置为5555setprop service.adb.tcp.port 5555对应的将端口设置为-1或者更小的数值,则将调试方式变为了usb调试setprop service.adb.tcp.port -1关闭adbstop adbd打开adbstart adbd好了有了这几个命令的基础,就可以实现usb和wifi调试方式的转换了
2.如何在android上执行shell
怎么执行,鬼才管呢。我又不是搞底层的。对于执行shell命令,自有高手早已写好的工具类,这里将源码贴上
public class ShellUtils {
public static final String COMMAND_SU = "su";
public static final String COMMAND_SH = "sh";
public static final String COMMAND_EXIT = "exit\n";
public static final String COMMAND_LINE_END = "\n";
private ShellUtils() {
throw new AssertionError();
* check whether has root permission
public static boolean checkRootPermission() {
return execCommand("echo root", true, false).result == 0;
* execute shell command, default return result msg
* @param command
* @param isRoot
whether need to run with root
* @see ShellUtils#execCommand(String[], boolean, boolean)
public static CommandResult execCommand(String command, boolean isRoot) {
return execCommand(new String[] { command }, isRoot, true);
* execute shell commands, default return result msg
* @param commands
command list
* @param isRoot
whether need to run with root
* @see ShellUtils#execCommand(String[], boolean, boolean)
public static CommandResult execCommand(List&String& commands,
boolean isRoot) {
return execCommand(
commands == null ? null : commands.toArray(new String[] {}),
isRoot, true);
* execute shell commands, default return result msg
* @param commands
command array
* @param isRoot
whether need to run with root
* @see ShellUtils#execCommand(String[], boolean, boolean)
public static CommandResult execCommand(String[] commands, boolean isRoot) {
return execCommand(commands, isRoot, true);
* execute shell command
* @param command
* @param isRoot
whether need to run with root
* @param isNeedResultMsg
whether need result msg
* @see ShellUtils#execCommand(String[], boolean, boolean)
public static CommandResult execCommand(String command, boolean isRoot,
boolean isNeedResultMsg) {
return execCommand(new String[] { command }, isRoot, isNeedResultMsg);
* execute shell commands
* @param commands
command list
* @param isRoot
whether need to run with root
* @param isNeedResultMsg
whether need result msg
* @see ShellUtils#execCommand(String[], boolean, boolean)
public static CommandResult execCommand(List&String& commands,
boolean isRoot, boolean isNeedResultMsg) {
return execCommand(
commands == null ? null : commands.toArray(new String[] {}),
isRoot, isNeedResultMsg);
* execute shell commands
* @param commands
command array
* @param isRoot
whether need to run with root
* @param isNeedResultMsg
whether need result msg
* @return &ul&
&li&if isNeedResultMsg is false, {@link CommandResult#successMsg}
is null and {@link CommandResult#errorMsg} is null.&/li&
&li&if {@link CommandResult#result} is -1, there maybe some
excepiton.&/li&
public static CommandResult execCommand(String[] commands, boolean isRoot,
boolean isNeedResultMsg) {
int result = -1;
if (commands == null || commands.length == 0) {
return new CommandResult(result, null, null);
Process process =
BufferedReader successResult =
BufferedReader errorResult =
StringBuilder successMsg =
StringBuilder errorMsg =
DataOutputStream os =
process = Runtime.getRuntime().exec(
isRoot ? COMMAND_SU : COMMAND_SH);
os = new DataOutputStream(process.getOutputStream());
for (String command : commands) {
if (command == null) {
// donnot use os.writeBytes(commmand), avoid chinese charset
os.write(command.getBytes());
os.writeBytes(COMMAND_LINE_END);
os.flush();
os.writeBytes(COMMAND_EXIT);
os.flush();
result = process.waitFor();
// get command result
if (isNeedResultMsg) {
successMsg = new StringBuilder();
errorMsg = new StringBuilder();
successResult = new BufferedReader(new InputStreamReader(
process.getInputStream()));
errorResult = new BufferedReader(new InputStreamReader(
process.getErrorStream()));
while ((s = successResult.readLine()) != null) {
successMsg.append(s);
while ((s = errorResult.readLine()) != null) {
errorMsg.append(s);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (os != null) {
os.close();
if (successResult != null) {
successResult.close();
if (errorResult != null) {
errorResult.close();
} catch (IOException e) {
e.printStackTrace();
if (process != null) {
process.destroy();
return new CommandResult(result, successMsg == null ? null
: successMsg.toString(), errorMsg == null ? null
: errorMsg.toString());
* result of command
* &li&{@link CommandResult#result} means result of command, 0 means normal,
* else means error, same to excute in linux shell&/li&
* &li&{@link CommandResult#successMsg} means success message of command
* result&/li&
* &li&{@link CommandResult#errorMsg} means error message of command result&/li&
* @author &a href="" target="_blank"&Trinea&/a&
public static class CommandResult {
/** result of command **/
/** success message of command result **/
public String successM
/** error message of command result **/
public String errorM
public CommandResult(int result) {
this.result =
public CommandResult(int result, String successMsg, String errorMsg) {
this.result =
this.successMsg = successM
this.errorMsg = errorM
我们需要用到的方法是
public static CommandResult execCommand(String[] commands, boolean isRoot,
boolean isNeedResultMsg) {
解释下三个参数的意思参数1:需要执行的命令数组参数2:是否已经root过。oh天,忘了说,你的手机必须要先root才能来做这件事情,至于root的方式,太多了,什么root大师,xx大师。参数3:是否需要返回结果,这个可有可无,如果你选择返回结果,我想多半是你想知道这些命令有没有执行成功,你只需要判断CommandResult .result的值是否为0,对的,linux就是这样,等于0就是成功了的意思ok,剩下的活你应该会做了,写一个button控件,监听点击事件,在事件中调用这个方法。至于参数一怎么写,当需要打开wifi调试的时候就这样写
String[] commands = {
setprop service.adb.tcp.port 5555,
stop adbd,
start adbd
当需要关闭wifi调试的时候,只需要将5555改为-1就行
3.pc端的命令
好的,现在你可以将apk编译到你的手机上,并且打开wifi调试,接着在如下目录
sdk\platform-tools
你可以通过 shift+右键 的方式有个“在此处打开命令行”。然后输入adb connect xxxxxxxx 是你的手机ip,端口不用输,默认就是5555,手机ip你可以在设置-关于手机-手机状态 中找到于是“噌”的一下,你的eclipse里的device窗口就显示你的破手机已经连接上了,现在你可以丢掉数据线,静静的装逼了。真是有逼格的烧连啊。断开连接,你可以在手机上断开,也可以在pc上通过
adb disconnect xxxx
来断开,当然在手机上断开保险一点。
好的,有问题的同学可以留言,啊哈哈哈哈哈,这都不会,你好笨啊。
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
被以下专题收入,发现更多相似内容:
Android老鸟给新人的建议、资源。
更优质的原创内容,欢迎关注技术公众号,微信搜索:“Open软件开发小组”或者“open_dev”
· 9352人关注
where there is a shell, there is a way.
· 13人关注
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
选择支付方式:

我要回帖

更多关于 cveigendecomposite 的文章

 

随机推荐