Runtime?runtime?=?Runtime.getRuntime();
創(chuàng)新互聯(lián)建站堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都做網(wǎng)站、網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的塔城網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
try?{
runtime.exec("cmd?/cls");
}?catch?(Exception?e)?{
System.out.println("Error!");
}
1、你先報(bào)名參加星際民航大學(xué)。
2、然后在星際民航大學(xué)里學(xué)習(xí)最基礎(chǔ)的知識(shí)。
3、之后大三就是你的分水嶺了,你可以選擇繼續(xù)上到大5,然后去民用星際星際飛船制造公司去工作,或者你選擇考星際軍校。
4、等你考上星際軍校之后你就可以真正的接觸軍用級(jí)的飛船了,但是前期還是理論知識(shí)和一些工廠殘次品給你們這些學(xué)員來(lái)練手。
5、等你成績(jī)很好,贏得上層重視?;蛘吣憧炭嗯W(xué)習(xí),終有一天獲得上層重視。這兩種只是時(shí)間的差別。
6、之后你就可以真正的加入高層培訓(xùn)班。這個(gè)時(shí)候就是你真正可以直接接觸軍用級(jí)的星際飛船了。
7、目前的星際飛船普遍采用java編寫(xiě),優(yōu)點(diǎn)就不說(shuō)了,以后你自然會(huì)知道。
——————我這是從3598年穿越回來(lái)給你回答的,我不了解你所在年份的情況,不過(guò)我所在年份都是這樣做的。
最近,使用Powershell腳本在A7 (8核,56G內(nèi)存)配置的 Azure VM(Virtual Machine,虛擬機(jī))上遠(yuǎn)程運(yùn)行Java JVM時(shí) (Java.exe -version),總是失敗并返回如下的錯(cuò)誤信息。同樣的Powershell腳本,在其它低于A7配置的VM上遠(yuǎn)程執(zhí)行一切正常;此外,如果使用遠(yuǎn)程桌面登錄到VM上,再進(jìn)行同樣的操作,一切執(zhí)行正常。
[plain] view plain copy
Error occurred during initialization of VM
Unable to allocate 458752KB bitmaps for parallel garbage collection for the requested 14680064KB heap.
Error occurred during initialization of VM
Could not reserve enough space for object heap
以上的實(shí)驗(yàn)排除了是JVM(1.7)本身的問(wèn)題, 看來(lái)問(wèn)題很有可能是出在Powershell的遠(yuǎn)程執(zhí)行方式上。Powershell Remoting依賴于WinRM (Windows Remote Management)在遠(yuǎn)程機(jī)器上執(zhí)行操作。默認(rèn)情況下,WinRM為每個(gè)Powershell遠(yuǎn)程連接分配了最大(MaxMemoryPerShellMB=1024)1G的內(nèi)存空間(早期的版本只有150M),用于執(zhí)行遠(yuǎn)程操作。但遠(yuǎn)程操作所需的執(zhí)行內(nèi)存空間 1G時(shí),就會(huì)出現(xiàn)了內(nèi)存不足的問(wèn)題,不同的操作可能表現(xiàn)會(huì)有所不同,如:有的會(huì)拋出OutOfMemoryException等。針對(duì)這個(gè)問(wèn)題,解決的辦法就是增加MaxMemoryPerShellMB,然后重啟WinRM服務(wù):
[plain] view plain copy
$maxMemoryPerShellVM = 3072
Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB $maxMemoryPerShellVM
Set-Item WSMan:\localhost\Plugin\Microsoft.PowerShell\Quotas\MaxMemoryPerShellMB $maxMemoryPerShellVM
Write-Output "List MaxMemoryPerShellMB configuration"
Get-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB
Get-Item WSMan:\localhost\Plugin\Microsoft.PowerShell\Quotas\MaxMemoryPerShellMB
# Restart WinRM service to make the change take effect
Restart-Service winrm
具體要增加到多大的內(nèi)存,需要自己去實(shí)驗(yàn)一下。
JAVA實(shí)現(xiàn)遠(yuǎn)程控制(JAVA in RemoteControl)
參考地址:【】
好復(fù)雜,希望能幫到您。
OpenOffice java api:
簡(jiǎn)單的說(shuō)就是利用java程序可以操作OpenOffice的所有功能,比如創(chuàng)建doc文檔,插入文字,設(shè)置文字格式等等。
1. OpenOffice 給程序員提供了一個(gè)叫UNO (UniversalNetwork Objects)的組件技術(shù).我理解的UNO: OpenOffice 類似于web程序中的服務(wù)器,程序員寫(xiě)的代碼類似于客戶端,利用UNO提供的接口和服務(wù)去完成對(duì)OpenOffice文檔的操作。所以寫(xiě)程序首先要搭建 UNO環(huán)境:
1. 下載 OpenOffice
2.復(fù)制UNO提供的jar包: unoil.jar, java_uno.jar, juh.jar, jurt.jar, ridl.jar, unoloader.jar. (ps: 安裝了SDK之后在文件夾找)到自己的工程中,引入它們。
3. 下載文檔:DevelopersGuide.pdf.
4. 安裝了SDK后,重新啟動(dòng)一下機(jī)器,然后就可以按照 DevelopersGuide 來(lái)學(xué)習(xí) UNO 編程了。
5. 需要ava 環(huán)境。
補(bǔ)充: 安裝了SDK后, java, c++幫助文檔,樣例程序,其他關(guān)于sdk的信息 都放在本地openOffice安裝路徑一個(gè)叫sdk目錄下面,enjoy it !
總結(jié)一下已經(jīng)實(shí)現(xiàn)的功能和碰到的問(wèn)題匯總:
1. 首先要得到遠(yuǎn)程office組件的上下文.通過(guò):
com.sun.star.uno.XComponentContext xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
得到,如果OpenOffice安裝路徑不是在工程的路徑下面(我自己猜的), 就會(huì)報(bào):
com.sun.star.comp.helper.BootstrapException: no office executable found!
解決辦法: 黑其源代碼, 看了源代碼就會(huì)發(fā)現(xiàn)其實(shí)OpenOffice是在尋找本地的soffice的shell文件,所以弄個(gè)變量來(lái)保存soffice在系統(tǒng)中的路徑,重新寫(xiě)一 個(gè)Bootstrap就可以了。詳細(xì)請(qǐng)參照:論壇 。
2. 得到 XMultiComponentFactory (ComponentFactory 工廠)
com.sun.star.lang.XMultiComponentFactory xMCF = xContext.getServiceManager();
3. 得到各種組件可以通過(guò)下面代碼:
// docType 是 與 soffice 同目錄下面的OpenOffice的其他shell文件,swrite等等
protected XComponent newDocComponent(String docType)
throws java.lang.Exception {
String loadUrl = "private:factory/" + docType;
mxRemoteServiceManager = this.getRemoteServiceManager();
Object desktop = mxRemoteServiceManager.createInstanceWithContext(
"com.sun.star.frame.Desktop", mxRemoteContext);
XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime
.queryInterface(XComponentLoader.class, desktop);
PropertyValue[] loadProps = new PropertyValue[0];
return xComponentLoader.loadComponentFromURL(loadUrl, "_blank", 0,
loadProps);
}
4.得到 XTextDocument
XComponent xEmptyWriterComponent = newDocComponent("swriter");
XTextDocument mxDoc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,
xEmptyWriterComponent);
5. 得到一個(gè)文檔的引用
XText mxDocText = mxDoc.getText();
6. 得到文檔的屬性列表
XPropertySet mxDocProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, mxDoc);
7. 建立光標(biāo),用來(lái)插入新的內(nèi)容。
XTextCursor mxDocCursor = mxDocText.createTextCursor();
XSentenceCursor xSentenceCursor = (XSentenceCursor) UnoRuntime
.queryInterface(XSentenceCursor.class, mxDocCursor);
XWordCursor xWordCursor = (XWordCursor) UnoRuntime.queryInterface(
XWordCursor.class, mxDocCursor);
8.得到光標(biāo)屬性列表
XPropertySet xCursorProps = (XPropertySet) UnoRuntime .queryInterface(XPropertySet.class, mxDocCursor);
9.設(shè)置插入文字格式
xCursorProps.setPropertyValue("CharFontName", "宋體");
xCursorProps.setPropertyValue("CharWeight", new Float(FontWeight.BOLD));
xCursorProps.setPropertyValue("CharHeight", new Float(10.5));
// 居中顯示
xCursorProps.setPropertyValue("ParaAdjust", com.sun.star.style.ParagraphAdjust.CENTER);
10.在該光標(biāo)處插入信息
mxDocText.insertString(xSentenceCursor, “Hello World", true);
11. 保存的關(guān)鍵代碼
protected void storeDocComponent(XComponent xDoc, String storeUrl)
throws java.lang.Exception {
XStorable xStorable = (XStorable) UnoRuntime.queryInterface(
XStorable.class, xDoc);
PropertyValue[] storeProps = new PropertyValue[1];
storeProps[0] = new PropertyValue();
storeProps[0].Name = "FilterName";
storeProps[0].Value = "MS Word 97";
openOfficeJavaLogger.debug("... store \"" + xDoc.toString() + "\" to \"" + storeUrl
+ "\".");
xStorable.storeAsURL(storeUrl, storeProps);
}
繼承了類,在方法里監(jiān)聽(tīng)了事件 在該類添加注冊(cè)了 基本就不會(huì)有什么問(wèn)題了
如果這個(gè)是你練習(xí)的項(xiàng)目,可以發(fā)我 我看一下
本文名稱:java遠(yuǎn)程控制源代碼,遠(yuǎn)程java開(kāi)發(fā)
文章位置:http://jinyejixie.com/article32/hchpsc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、企業(yè)建站、標(biāo)簽優(yōu)化、做網(wǎng)站、網(wǎng)站維護(hù)、網(wǎng)站收錄
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)