java 代碼開啟一個dos視窗

來源:互聯網
上載者:User

try {<br /> Runtime.getRuntime()<br /> .exec("cmd.exe /C start", null, new File("c:/"));<br /> System.out.println("finish");<br /> } catch (IOException e) {<br /> e.printStackTrace();<br /> }

可以通過java 代碼開啟一個dos視窗

if (selection instanceof IStructuredSelection) {<br /> Object sel = ((IStructuredSelection)selection).getFirstElement();</p><p> if (sel instanceof PlatformObject) {<br /> PlatformObject p = (PlatformObject)sel;<br /> IResource resource = (IResource)p.getAdapter(IResource.class);<br /> if (resource != null) {<br /> return getPath(resource);<br /> }<br /> }<br /> if (sel instanceof IResource) {<br /> IResource res = (IResource)sel;<br /> if (res != null) {<br /> return getPath(res);<br /> }<br /> }</p><p> if (sel instanceof IJavaElement) {<br /> IJavaElement je = (IJavaElement)sel;<br /> try {<br /> IResource correspondingResource = je.getCorrespondingResource();<br /> if (correspondingResource != null)<br /> getPath(correspondingResource);<br /> }<br /> catch (JavaModelException localJavaModelException) {<br /> }<br /> }<br /> if (sel instanceof IPluginModel) {<br /> IPluginModel mod = (IPluginModel)sel;<br /> String installLocation = mod.getInstallLocation();<br /> return installLocation;<br /> }<br /> if (sel instanceof IJarEntryResource) {<br /> IJarEntryResource jar = (IJarEntryResource)sel;<br /> IPath fullPath = jar.getFullPath();</p><p> return fullPath.makeAbsolute().toOSString();<br /> }</p><p> if (sel instanceof IAdaptable) {<br /> IAdaptable ad = (IAdaptable)sel;</p><p> IResource resource = (IResource)ad.getAdapter(IResource.class);<br /> if (resource != null) {<br /> return getPath(resource);<br /> }<br /> }

根據ISelection取得 ISelection得到的資源路徑

public void logError(String msg, Throwable t) {<br /> ILog log = getDefault().getLog();<br /> Status s = new Status(4, PLUGIN_ID, msg, t);<br /> log.log(s);<br />}

外掛程式在啟動並執行時候運行System.out.println 是不起作用的,必須使用記錄日誌的方式來顯示列印資訊,可以用以上方式

 

mvn 執行java main程式:

mvn exec:java -Dexec.mainClass=com.koubei.kac.alipaytaobaocooperate.CAEAlipayCooperate

詳細:http://mojo.codehaus.org/exec-maven-plugin/java-mojo.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.