nusCS2113-AY1920S1 / forum

Discussion forums
MIT License
9 stars 2 forks source link

Open the same JAR in Window, Mac and Linux Platforms <title updated from original> #84

Open qjie7 opened 5 years ago

qjie7 commented 5 years ago

Hi all , this happened to my group after one of our only window user tried to open jar file today. Did anybody face the same problem before ? It will be great to share your experience here while i continue searching for an answer now. 351572515485_ pic_hd

saiganeshsuresh commented 5 years ago

Hi QJ,

Did not come across this issue myself but I think this stackoverflow post would help you streamline your debugging!

https://stackoverflow.com/questions/2861592/possible-to-run-jar-file-on-any-os

okkhoy commented 5 years ago

@qjie7 does these help:

qjie7 commented 5 years ago

Thank you for the response. I will wait for my team member to try out the suggestions provided. Thank you.

sevenmatt7 commented 5 years ago

Is the Java installed Java from Oracle or OpenJDK?

qjie7 commented 5 years ago

Is the Java installed Java from Oracle or OpenJDK?

hi , i believe should be from Oracle site

sevenmatt7 commented 5 years ago

Ok, try to install OpenJDK. Follow the steps below

  1. Download openJDK 11 here https://jdk.java.net/java-se-ri/11

  2. Install openJDK following these instructions https://stackoverflow.com/questions/52511778/how-to-install-openjdk-11-on-windows

  3. go to your command prompt and type in 'java -version' and make sure it is showing OpenJDK11

Then try to run your jar file again.

If not, maybe you can give me a link to your jar? I will try to run it on my computer.

sevenmatt7 commented 5 years ago

Hi, can you type in java -version into your terminal and tell me what you see

qjie7 commented 5 years ago
Screenshot 2019-11-01 at 4 45 29 PM

Here you go. I will try to install OpenJDK11 after lecture :D thank you so much

sevenmatt7 commented 5 years ago

If you are still facing the same issue, I suggest that you check what Java version (8,11, OpenJDK, Java SE) you packaged and built the JAR file with. Make sure that the system you want to run the JAR file on is also running the same version of Java as the system that you packaged your JAR file with, regardless of the platform.

If you had followed the build.gradle file dependencies from any of the reference repos (e,g addressbook), the packaging and building of the JavaFX should be correct because it installs the libraries for all the platforms.

If you used the gradle plugin, it should be the same case.

sevenmatt7 commented 5 years ago

Try including this if you have not in your build.gradle file

sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11

saiganeshsuresh commented 5 years ago

The issue for projects with a GUI utilizing java FX based implementation require this to be added in the dependency under the build.gradle to make it work on other Operating Systems. Created on Win and tested it on a Mac and it works. dependencies { String javaFxVersion = '11' implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win' implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac' implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux' implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win' implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac' implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux' implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win' implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac' implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux' implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win' implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac' implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux' . . . . }

okkhoy commented 5 years ago

Goes on to prove most of you didn't bother to read https://github.com/nusCS2113-AY1920S1/forum/issues/65 😜

qjie7 commented 5 years ago

Goes on to prove most of you didn't bother to read #65 😜

oops! totally forgot about this issue. Thanks prof!

okkhoy commented 5 years ago

reopening this a PSA

Deculsion commented 5 years ago

Hi we have tried the solution posted in #65 but our team is still having issues running the jar on each other's OS. A jar file built on Windows only works on a windows machine, likewise for OSx. We tried building a jar on both OSes and running it on each other's OS. This is the error output when running the jars.

It seems that only the first line of error output is any different. Built on OSx, run in Windows: image

Built on Windows, run in OSx: WhatsApp Image 2019-11-07 at 3 23 58 PM (1)

This is our java versions: Windows: image OSx: WhatsApp Image 2019-11-07 at 3 23 58 PM

This is our build.gradle file.

plugins {
    id 'java'
    id 'application'
    id 'checkstyle'
    id 'com.github.johnrengelman.shadow' version '5.1.0'
    id 'org.openjfx.javafxplugin' version '0.0.7'
}

checkstyle {
    toolVersion ='8.23'
}

shadowJar {
    archiveBaseName = "eggventory"
    archiveVersion = "1.3.1"
    archiveClassifier = null
    archiveAppendix = null
}
group 'seedu.eggventory'
version '0.1.0'

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter:5.5.0'
    String javaFxVersion = '11'

    implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
    implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
    implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux'
    implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win'
    implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac'
    implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux'
    implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win'
    implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac'
    implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux'
    implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
    implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
    implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'
}

javafx {
    version = "11.0.2"
    modules = [ 'javafx.controls', 'javafx.fxml' ]
}

test {
    useJUnitPlatform()
}

repositories {
    mavenCentral()
}

application {
    // Change this to your main class.
    mainClassName = "eggventory.Eggventory"
}

run {
    standardInput = System.in
}
saiganeshsuresh commented 5 years ago

Hi you have to remove the javafx {...} portion! This helped mine!

Get Outlook for iOShttps://aka.ms/o0ukef


From: Dana Poon notifications@github.com Sent: Thursday, November 7, 2019 3:31:23 PM To: nusCS2113-AY1920S1/forum forum@noreply.github.com Cc: Sai Ganesh Suresh e0310898@u.nus.edu; Comment comment@noreply.github.com Subject: Re: [nusCS2113-AY1920S1/forum] Open the same JAR in Window, Mac and Linux Platforms (#84)</p> <p>Hi we have tried the solution posted in #65<a href="https://github.com/nusCS2113-AY1920S1/forum/issues/65">https://github.com/nusCS2113-AY1920S1/forum/issues/65</a> but our team is still having issues running the jar on each other's OS. A jar file built on Windows only works on a windows machine, likewise for OSx. We tried building a jar on both OSes and running it on each other's OS. This is the error output when running the jars.</p> <p>It seems that only the first line of error output is any different. Built on OSx, run in Windows: [image]<a href="https://user-images.githubusercontent.com/42791813/68368415-fcf47480-0172-11ea-9179-a35e272f5782.png">https://user-images.githubusercontent.com/42791813/68368415-fcf47480-0172-11ea-9179-a35e272f5782.png</a></p> <p>Built on Windows, run in OSx: [WhatsApp Image 2019-11-07 at 3 23 58 PM (1)]<a href="https://user-images.githubusercontent.com/42791813/68368375-e5b58700-0172-11ea-9215-5e27824c4863.jpeg">https://user-images.githubusercontent.com/42791813/68368375-e5b58700-0172-11ea-9215-5e27824c4863.jpeg</a></p> <p>This is our java versions: Windows: [image] <a href="https://user-images.githubusercontent.com/42791813/68366675-e0563d80-016e-11ea-8230-c4917324e466.png">https://user-images.githubusercontent.com/42791813/68366675-e0563d80-016e-11ea-8230-c4917324e466.png</a> OSx: [WhatsApp Image 2019-11-07 at 3 23 58 PM] <a href="https://user-images.githubusercontent.com/42791813/68368309-bdc62380-0172-11ea-8746-9760217669bb.jpeg">https://user-images.githubusercontent.com/42791813/68368309-bdc62380-0172-11ea-8746-9760217669bb.jpeg</a></p> <p>This is our build.gradle file.</p> <p>plugins { id 'java' id 'application' id 'checkstyle' id 'com.github.johnrengelman.shadow' version '5.1.0' id 'org.openjfx.javafxplugin' version '0.0.7' }</p> <p>checkstyle { toolVersion ='8.23' }</p> <p>shadowJar { archiveBaseName = "eggventory" archiveVersion = "1.3.1" archiveClassifier = null archiveAppendix = null } group 'seedu.eggventory' version '0.1.0'</p> <p>dependencies { testImplementation 'org.junit.jupiter:junit-jupiter:5.5.0' String javaFxVersion = '11'</p> <pre><code>implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win' implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac' implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux' implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win' implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac' implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux' implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win' implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac' implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux' implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win' implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac' implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'</code></pre> <p>}</p> <p>javafx { version = "11.0.2" modules = [ 'javafx.controls', 'javafx.fxml' ] }</p> <p>test { useJUnitPlatform() }</p> <p>repositories { mavenCentral() }</p> <p>application { // Change this to your main class. mainClassName = "eggventory.Eggventory" }</p> <p>run { standardInput = System.in }</p> <p>— You are receiving this because you commented. Reply to this email directly, view it on GitHub<a href="https://github.com/nusCS2113-AY1920S1/forum/issues/84?email_source=notifications&email_token=AKFWHRR37BLYG5PROQAUONTQSO74XA5CNFSM4JHISFR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDLPRJQ#issuecomment-550959270">https://github.com/nusCS2113-AY1920S1/forum/issues/84?email_source=notifications&email_token=AKFWHRR37BLYG5PROQAUONTQSO74XA5CNFSM4JHISFR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDLPRJQ#issuecomment-550959270</a>, or unsubscribe<a href="https://github.com/notifications/unsubscribe-auth/AKFWHRUIQ5JMCTZO2J2OWKDQSO74XANCNFSM4JHISFRQ">https://github.com/notifications/unsubscribe-auth/AKFWHRUIQ5JMCTZO2J2OWKDQSO74XANCNFSM4JHISFRQ</a>.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Deculsion"><img src="https://avatars.githubusercontent.com/u/42791813?v=4" />Deculsion</a> commented <strong> 5 years ago</strong> </div> <div class="markdown-body"> <p>That worked. Thanks!</p> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>