Page 1 of 2 12 LastLast
Results 1 to 20 of 27
  1. #1
    nat
    nat is offline Member
    Join Date
    Dec 2013
    Posts
    56
    Rep Power
    0

    Default .jar file is not working on a machine with no installed java developing environment

    Hi,
    I have a .jar file, but when double clicking on it on a machine with installed only java runtime environment, and not installed java development environment, a window is opened with a message "Could not find the main class. Program will exit". But if I double click it on a machine with installed NetBean or Eclipse, it works, i.e. an application starts.

    Could somebody help me please why the file doesn't work on a machine with no installed java development environment?

    Thank you very much in advance.
    Last edited by nat; 12-08-2013 at 09:19 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,812
    Rep Power
    25

    Default Re: .jar file is not working on a machine with no installed java developing environme

    Can you open a command prompt window and enter the command: java -jar <THEJARFILENAMEHERE>
    copy the contents of the command prompt window and paste it here.
    Last edited by Norm; 12-09-2013 at 02:45 AM.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    nat
    nat is offline Member
    Join Date
    Dec 2013
    Posts
    56
    Rep Power
    0

    Default Re: .jar file is not working on a machine with no installed java developing environme

    Thanks Norm. I am very new in Java, and I am not sure I understand well the answer. I used C# before. Now I have only the jar file and should find out how it works and similar things. I opened the Command Prompt on my computer and by default the path when it opens is C:\Documents and settings\Nameoftheuser> and I wrote the command you've recommend me after this prompt sign. But I got this:
    The syntax of the command is incorrect.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,269
    Rep Power
    6

    Default Re: .jar file is not working on a machine with no installed java developing environme

    The fact that it works on machines with a development kit and that it does not work on a machine with only a runtime is a red herring - it is not the cause of the jar not running. I would first investigate the versions of Java installed on the different environments to see if there is a difference there.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,812
    Rep Power
    25

    Default Re: .jar file is not working on a machine with no installed java developing environme

    Can you copy the full contents of the command prompt window and paste it here?
    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,269
    Rep Power
    6

    Default Re: .jar file is not working on a machine with no installed java developing environme

    You can also right-click in the command prompt to copy the selection to the clipboard ;)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    nat
    nat is offline Member
    Join Date
    Dec 2013
    Posts
    56
    Rep Power
    0

    Default Re: .jar file is not working on a machine with no installed java developing environme

    Here is the full conent in the Command Prompt:

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\laptopAOP>java -jar <hereIwrotethenameofthejarfile>
    The syntax of the command is incorrect.

    C:\Documents and Settings\laptopAOP>

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,812
    Rep Power
    25

    Default Re: .jar file is not working on a machine with no installed java developing environme

    The <>s were meta symbols used to surround text to be replaced with valid text, they are NOT used on the commandline.
    Use something like this: java -jar AjarFile.jar
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    nat
    nat is offline Member
    Join Date
    Dec 2013
    Posts
    56
    Rep Power
    0

    Default Re: .jar file is not working on a machine with no installed java developing environme

    All right, thanks a lot Norm.
    Here is what I get now in the Command Prompt:

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\laptopAOP>java -jar nameofthefile.jar
    Exception in thread "main" java.util.zip.ZipException: The system cannot find th
    e file specified
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(Unknown Source)
    at java.util.jar.JarFile.<init>(Unknown Source)
    at java.util.jar.JarFile.<init>(Unknown Source)

    C:\Documents and Settings\laptopAOP>

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,812
    Rep Power
    25

    Default Re: .jar file is not working on a machine with no installed java developing environme

    I've never seen that error message and have no idea what is happening. Is that the full text of the message? It's unusual that it doesn't show a source code line number.
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    nat
    nat is offline Member
    Join Date
    Dec 2013
    Posts
    56
    Rep Power
    0

    Default Re: .jar file is not working on a machine with no installed java developing environme

    Yes, that is the full text, except the name of the file, everything is exactly the same. I selected all text and copied as you explained to me.
    I didn't have the source code, so I used the jar file and java decompiler to see the code.

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,812
    Rep Power
    25

    Default Re: .jar file is not working on a machine with no installed java developing environme

    Ask the author of the code about that ZipFile error message.
    If you don't understand my response, don't ignore it, ask a question.

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,178
    Rep Power
    20

    Default Re: .jar file is not working on a machine with no installed java developing environme

    What version of Java is on that machine?
    Do:
    java -version

    That looks like it's having problems with the jar file?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  14. #14
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,269
    Rep Power
    6

    Default Re: .jar file is not working on a machine with no installed java developing environme

    Yeah I was thinking the same, if it was an exception caused by the code I would expect a stacktrace with the program's main() at the root of it. But if I run that command (using Java 6) on a non-existent jar file I get the simple error "Unable to access jarfile name.jar" and if I run it on a file that is in fact not a jar, I get the error " Invalid or corrupt jarfile name.jar". But perhaps a different version of Java produces a different result...
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  15. #15
    nat
    nat is offline Member
    Join Date
    Dec 2013
    Posts
    56
    Rep Power
    0

    Default Re: .jar file is not working on a machine with no installed java developing environme

    Hi,
    It is 1.4.2. Here is the the full content of Cmmand Prompt with the java version:

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\laptopAOP>java -version
    java version "1.4.2"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
    Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

    C:\Documents and Settings\laptopAOP>

  16. #16
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,178
    Rep Power
    20

    Default Re: .jar file is not working on a machine with no installed java developing environme

    Well, that's really quite old.
    What version of Java was the jar file compiled on?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  17. #17
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,812
    Rep Power
    25

    Default Re: .jar file is not working on a machine with no installed java developing environme

    That is a very old version of java. Older versions of java do NOT work with code generated for the current version of java.
    If you don't understand my response, don't ignore it, ask a question.

  18. #18
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,178
    Rep Power
    20

    Default Re: .jar file is not working on a machine with no installed java developing environme

    Ah, right.
    Bit more digging.
    This bug might help identify the problem.
    Now it's the last entry that seems to hold the key, but I'm not sure my interpretation is correct:
    "
    The FileNotFoundException is thrown on Windows platform alreays after switched to winFileHandleOpen for long path support.
    "
    That seems to imply it's a problem with path lengths?
    Try and run the jar file from a (short named) directory off the C: drive.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  19. #19
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,178
    Rep Power
    20

    Default Re: .jar file is not working on a machine with no installed java developing environme

    Quote Originally Posted by Norm View Post
    That is a very old version of java. Older versions of java do NOT work with code generated for the current version of java.
    Should still get the version error rather than the above.
    But I fully expect (if the Zip error problem is ever resolved) that that error will occur...:)
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  20. #20
    nat
    nat is offline Member
    Join Date
    Dec 2013
    Posts
    56
    Rep Power
    0

    Default Re: .jar file is not working on a machine with no installed java developing environme

    I have only the jar file, and for me to be able to see the code, using this jar file, I used Java decompiler (JD-GUI) version 0.3.6 (JD-CORE is version 0.7.0.1)

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 06-04-2013, 12:52 PM
  2. Replies: 10
    Last Post: 02-28-2012, 09:44 PM
  3. Replies: 0
    Last Post: 12-21-2011, 10:15 AM
  4. Replies: 1
    Last Post: 07-28-2011, 08:50 PM
  5. Replies: 0
    Last Post: 02-07-2011, 02:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •