2012-04-23 28 views

回答

4

下面是使用codebase示例JNLP,設置一個桌面圖標和飛濺 屏幕。請參閱oracle頁面JNLP文件的結構和較早的文檔: Java網絡啓動協議和API規範(JSR-56)非常全面。

<?xml version="1.0" encoding="utf-8"?> 
<!-- JNLP File for YourWebstart --> 
<jnlp 
spec="1.5+" 
codebase="http://YourWebsiteurl.com/YourWeblaunchPage" 
href=」Your.jnlp"> 
<information> 
    <title>YourPrograms</title> 
    <vendor>YourCompany</vendor> 
    <description>Your application</description> 
    <description kind="short">Your weblaunch description</description> 
    <icon href="YourdesktopIconLogo.png"/> 
    <icon kind="splash" href="YourSplashScreenImage.png"/> 
    <shortcut online="true"> 
    <desktop/> 
    </shortcut> 
    </information> 
    <security> 
    <all-permissions/> 
    </security> 
    <resources> 
    <j2se version="1.6+" 
    href="http://java.sun.com/products/autodl/j2se"/>  
    <jar href="YourApplication.jar"/> 
    </resources> 
    <application-desc main-class="YourMainClassLocation.YourMainClass"> 
    <argument>AnyArgumentsYouWantToPassIntoYourApplication</argument> 
</application-desc> 
</jnlp> 
2

基於codebase的文件不會在部署的時候工作,並在開發過程中,一個基於Web的代碼庫可以在運行時被覆蓋。

要獲取基於文件的URL進行測試,請在感興趣的目錄中創建一個File對象,那麼JNLP文件可能是最好的。檢查file.exists()(檢查我們的假設非常重要),然後撥打file.toURI().toURL()將其作爲文件庫URL。

此外,請務必使用JaNeLA檢查JNLP。

1

答案標記爲正確是正確的,當你使用一個Web服務器,但是如果你使用的文件系統必須滿足以下要求才能使用當前目錄作爲代碼庫使用

<jnlp href="launch.jnlp" spec="1.0+"> 

這個工程使用JDK 1.7.0_25

相關問題