Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
qjie7 opened this issue Oct 31, 2019 · 17 comments

Comments

@qjie7
Copy link

qjie7 commented Oct 31, 2019

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
Copy link

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

@qjie7
Copy link
Author

qjie7 commented Oct 31, 2019

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

@sevenmatt7
Copy link

Is the Java installed Java from Oracle or OpenJDK?

@qjie7
Copy link
Author

qjie7 commented Nov 1, 2019

Is the Java installed Java from Oracle or OpenJDK?

hi , i believe should be from Oracle site

@sevenmatt7

This comment has been minimized.

@sevenmatt7
Copy link

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

@qjie7
Copy link
Author

qjie7 commented Nov 1, 2019

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
Copy link

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
Copy link

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

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

@saiganeshsuresh
Copy link

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
Copy link
Collaborator

okkhoy commented Nov 1, 2019

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

@qjie7
Copy link
Author

qjie7 commented Nov 1, 2019

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

oops! totally forgot about this issue. Thanks prof!

@qjie7 qjie7 closed this as completed Nov 1, 2019
@okkhoy
Copy link
Collaborator

okkhoy commented Nov 2, 2019

reopening this a PSA

@okkhoy okkhoy reopened this Nov 2, 2019
@okkhoy okkhoy changed the title [Help] Jar file unable to open in Window Platform , but work in Unix(mac) Open the same JAR in Window, Mac and Linux Platforms <title updated from original> Nov 2, 2019
@okkhoy okkhoy pinned this issue Nov 2, 2019
@Deculsion
Copy link

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
Copy link

saiganeshsuresh commented Nov 7, 2019 via email

@Deculsion
Copy link

That worked. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants