• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jar runs on desktop but not laptop

 
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have clean & build my project in netbeans which run fines in my desktop , the executable jar was in my project folders dest folder and the executable jar has java's icons ,
but the problem is when i run the same folder in my laptop which has java and jdk class path is set in environment variable in other words its also my development machine
but there i cant run that same project or jar files , when i run that it says no class or jar found at that location but i can see the jar file in the path , c/desktop/jtext/dist/jtextpane.jar
but jvm launcher says that jar file does not exit in the same location
what can i do now ?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exactly how are you trying to "run the same folder"?

Bill
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Brogden wrote:Exactly how are you trying to "run the same folder"?

Bill



i m launching the classname.jar by double clicking on the jar but it throws an error saying noclassdeffound etc
but i m able to launch the same app from cmd
then what is the problem with double clicking the app's jar file ?
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
javaw has a nasty habit of displaying the same error message for any throwable that's thrown from the main method.

How are you launching the JVM from the command line?
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:javaw has a nasty habit of displaying the same error message for any throwable that's thrown from the main method.

How are you launching the JVM from the command line?


hi rob , problem is when i m launching from command line my app.jar runs fine
  • but when i double click the jar it says noclassDeffound when i try to open with java se binary (jar association is java)
  • and when i double click the jar it says no class found in the directory and shows me the path of my deirectory but this it is launched by javaw se binary (jar association is javaw)


  • i have also try to set the classpath like .; and the directory which contains the jar file like for eg classpath = .;c//desktop/jtextpane/dest/myapp.jar but nothing seems to be working

    note : this jar is build on my desktop & works fine in my desktop , problem arises when i try to make a zip and distribute it to my users so for eg : in this case consider user is my laptop
    now can you help me ?
     
    Rob Spoor
    Sheriff
    Posts: 22781
    131
    Eclipse IDE Spring VI Editor Chrome Java Windows
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You did not answer my question. What do you enter on the command line when it runs fine?
     
    Ranch Hand
    Posts: 4716
    9
    Scala Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    rob is probably your best hope for a good answer, but i will just mention this in case it applies. maybe the laptop has an older version of the JRE. i have had a problem with this when compiling an Applet in java7 and my browser only finds java6 runtime.
     
    naved momin
    Ranch Hand
    Posts: 692
    Eclipse IDE Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Rob Spoor wrote:You did not answer my question. What do you enter on the command line when it runs fine?

    hi rob
    i started my app.jar like
     
    Rob Spoor
    Sheriff
    Posts: 22781
    131
    Eclipse IDE Spring VI Editor Chrome Java Windows
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    To be honest, I doubt it. Windows doesn't use forward slashes as path separators but backslashes. Perhaps you meant that that is the current path; then it would work. It would also mean that double clicking the JAR file (which does little more than call javaw.exe -jar Myapp.jar) should work as well. If it doesn't it's probably a class path issue. Did you set the class path inside that command line window? Or did you set it up as an environment variable? Either way, the preferred way of setting class paths for JAR files is to put it in the JAR's MANIFEST.MF file, as the value of the Class-Path attribute. See this for more information.
     
    naved momin
    Ranch Hand
    Posts: 692
    Eclipse IDE Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Rob Spoor wrote:To be honest, I doubt it. Windows doesn't use forward slashes as path separators but backslashes. Perhaps you meant that that is the current path; then it would work. It would also mean that double clicking the JAR file (which does little more than call javaw.exe -jar Myapp.jar) should work as well. If it doesn't it's probably a class path issue. Did you set the class path inside that command line window? Or did you set it up as an environment variable? Either way, the preferred way of setting class paths for JAR files is to put it in the JAR's MANIFEST.MF file, as the value of the Class-Path attribute. See this for more information.



    i got this mf file from inside my jar file
    strange thing was the class path is not set ...and i have tried setting it manually but this too doesn't solve my problem
    note : the main class is correct package is jtextpanedemo and class is JTextPaneDemo
     
    Rob Spoor
    Sheriff
    Posts: 22781
    131
    Eclipse IDE Spring VI Editor Chrome Java Windows
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    That java -jar Myapp.jar command is working on your desktop. Is it also working on your laptop? I still think there is a class path issue. Maybe it's not in the CLASSPATH environment variable, but some library you put in the /lib/ext sub folder of the JRE installation.
    On the other hand, the cause could be something completely different. Perhaps you're trying to read from a file that doesn't exist on the laptop, or you have no rights to read that file. Likewise for writing a file or creating a directory.
     
    naved momin
    Ranch Hand
    Posts: 692
    Eclipse IDE Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    That java -jar Myapp.jar command is working on your desktop

    .

    yes , it works any way in my desktop from cmd or just by double click ..no problem in my desktop

    Is it also working on your laptop?



    from command line or cmd it works fine let me give you the complete command i use

    I still think there is a class path issue

    .
    i think that too ..
    the measure i have taken to solve class path issue was
    i have included classpath = .;c;C:\Users\Admin\Desktop\JTextPaneDemo\dest\java -jar JTextPaneDemo.jar
    but didnt got success

    Maybe it's not in the CLASSPATH environment variable,


    i m setting the classpath (stated above)in the environment variable only
    under user variables for admin

    but some library you put in the /lib/ext sub folder of the JRE installation.


    i have not putted any lib in this project nor in at the installation time of JRE

    On the other hand, the cause could be something completely different. Perhaps you're trying to read from a file that doesn't exist on the laptop, or you have no rights to read that file. Likewise for writing a file or creating a directory



    i m admin so this should not be the case .
    i have full writes rwx
    or 777 in unix words
     
    Marshal
    Posts: 28177
    95
    Eclipse IDE Firefox Browser MySQL Database
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Nobody seems to have mentioned yet that "java -jar something.jar" ignores any classpath settings, except for those specified as "Class-Path" entries in the jar's manifest.
     
    naved momin
    Ranch Hand
    Posts: 692
    Eclipse IDE Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Paul Clapham wrote:Nobody seems to have mentioned yet that "java -jar something.jar" ignores any classpath settings, except for those specified as "Class-Path" entries in the jar's manifest.


    so you mean i need to set the classpath in the menifiest file inside the "something.jar"
    which is empty for now
     
    naved momin
    Ranch Hand
    Posts: 692
    Eclipse IDE Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Paul Clapham wrote:Nobody seems to have mentioned yet that "java -jar something.jar" ignores any classpath settings, except for those specified as "Class-Path" entries in the jar's manifest.


    so no answers i guess , now i m thinking making jars for distributing the code is a hell ,
    it could run or not depends on the destiny of the end user ...lol
    i guess exe is much better options for windows platform
     
    author
    Posts: 23951
    142
    jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    naved momin wrote:

    Paul Clapham wrote:Nobody seems to have mentioned yet that "java -jar something.jar" ignores any classpath settings, except for those specified as "Class-Path" entries in the jar's manifest.


    so you mean i need to set the classpath in the menifiest file inside the "something.jar"
    which is empty for now



    That depends. Does your jar files depend on external jar files (or any external classes)? If it does, then yes, you need to have those jar files also copied over to the other machine, and your jar files needs to reference it.

    If it doesn't, then empty "Class-Path" should be fine.

    Henry
     
    naved momin
    Ranch Hand
    Posts: 692
    Eclipse IDE Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Henry Wong wrote:

    naved momin wrote:

    Paul Clapham wrote:Nobody seems to have mentioned yet that "java -jar something.jar" ignores any classpath settings, except for those specified as "Class-Path" entries in the jar's manifest.


    so you mean i need to set the classpath in the menifiest file inside the "something.jar"
    which is empty for now



    That depends. Does your jar files depend on external jar files (or any external classes)? If it does, then yes, you need to have those jar files also copied over to the other machine, and your jar files needs to reference it.

    If it doesn't, then empty "Class-Path" should be fine.

    Henry


    k , but any way the jar is not running from double click and runs fine through cmd with the fully qualified path to the jar files (absolute path)
     
    Henry Wong
    author
    Posts: 23951
    142
    jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    naved momin wrote:
    so no answers i guess , now i m thinking making jars for distributing the code is a hell ,
    it could run or not depends on the destiny of the end user ...lol
    i guess exe is much better options for windows platform



    Just because the distribute is different, doesn't mean that one is easier than the other.

    You have this same exact issue, if you try to distribute a DLL, and it depends on an external DLL. You still need to copy dependent DLLs over, and have them in your library paths.

    Henry
     
    Henry Wong
    author
    Posts: 23951
    142
    jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    naved momin wrote:
    k , but any way the jar is not running from double click and runs fine through cmd with the fully qualified path to the jar files (absolute path)



    On the same machine? Easily. If the command line environment and the windows environment are configured differently -- and depending on what you application is doing, it could be anything.... I recommend writing a quick and dirty script that dumps all the environment variables and see what is different. That should give you a place to start to look.

    On a different machine? Easily times ten. Different software packages installed. Different versions installed. Different OS version. Different hardware configurations. Different hardware. etc.

    Henry
     
    Those are the largest trousers in the world! Especially when next to this ad:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic