This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 258083 - .jar file won't run
Summary: .jar file won't run
Status: RESOLVED WORKSFORME
Alias: None
Product: ide
Classification: Unclassified
Component: BlueJ (show other bugs)
Version: 8.1
Hardware: PC Other
: P1 normal (vote)
Assignee: issues@ide
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-21 10:48 UTC by EddieDominguez
Modified: 2016-03-17 12:05 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
captured screen of the error given (433.99 KB, image/png)
2016-02-21 10:48 UTC, EddieDominguez
Details
the asked problematic .jar file (1.21 KB, application/java-archive)
2016-02-22 19:40 UTC, EddieDominguez
Details
captured screen of the error given and the folder and cmd window (1.18 MB, image/png)
2016-02-27 06:45 UTC, EddieDominguez
Details
screenshots of cmd (2.73 MB, image/png)
2016-02-27 21:10 UTC, EddieDominguez
Details
update (2.73 MB, image/png)
2016-02-27 21:16 UTC, EddieDominguez
Details
the java version both in netbeans and in cmd (1.39 MB, image/png)
2016-03-01 15:54 UTC, EddieDominguez
Details

Note You need to log in before you can comment on or make changes to this bug.
Description EddieDominguez 2016-02-21 10:48:13 UTC
Created attachment 158583 [details]
captured screen of the error given

When run from within Netbeans the projcets work fine. However after building the project (any project, even something as simple as a fresh new project with a System.out.println("hello world"); line and nothing more)and travelling in windows to the project's folder\dist and trying to run the generated jar file, constantly a popup error occurs: "Could not find the main class: project.classname. Program will exit" (see attached file to see the error)

I've recently installed the new version of Netbeans with Java. Could this be the problem? I haven't had this issue before.

from the about, these are my settings:

Product Version: NetBeans IDE 8.1 (Build 201510222201)
Updates: NetBeans IDE is updated to version NetBeans 8.1 Patch 1
Java: 1.8.0_73; Java HotSpot(TM) 64-Bit Server VM 25.73-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_73-b02
System: Windows 10 version 10.0 running on amd64; Cp1255; iw_IL (nb)
Comment 1 Jiri Prox 2016-02-22 15:55:11 UTC
Can you please attach the problematic jar?
What type of project do you use?

Thanks
Comment 2 EddieDominguez 2016-02-22 19:40:12 UTC
Created attachment 158602 [details]
the asked problematic .jar file

Here's an example of a problematic .jar file
Comment 3 EddieDominguez 2016-02-22 19:41:57 UTC
sorry, I forgot to answer this. The project I'm using is a regular java application
Comment 4 Jiri Prox 2016-02-23 08:39:59 UTC
The jar I've posted works correctly for me. There is probably something wrong with the .jar association in your system. 
The correct command to run this jar should be: "java -jar HelloWorld.jar"

Please try run this in command line (java_home/bin must be in the PATH variable).
If it still does not work, please attach output of this command
Comment 5 EddieDominguez 2016-02-23 16:07:10 UTC
I'm sorry, I don't understand. I'm not very knowledgable about operating systems beyond simple use. Where do I find this command line?

do you mean type in "c:\...\my project folder\bin\java -jar HelloWorld.jar" somewhere?
Comment 6 Jiri Prox 2016-02-25 11:59:20 UTC
On windows just run "cmd.exe" program. It will open the command line. 
The cd to your project directory and type:

...java home...\bin\java -jar HelloWorld.jar
Comment 7 EddieDominguez 2016-02-27 06:45:25 UTC
Created attachment 158663 [details]
captured screen of the error given and the folder and cmd window
Comment 8 Jiri Prox 2016-02-27 20:39:34 UTC
Thanks for info. 
Can you please try typing simply "java" and "java -jar HelloWorld.jar" commands?
Comment 9 EddieDominguez 2016-02-27 21:10:40 UTC
Created attachment 158668 [details]
screenshots of cmd
Comment 10 EddieDominguez 2016-02-27 21:16:43 UTC
Created attachment 158669 [details]
update

wait, i've done it in the dist folder and it gave me the hello world. does that mean it worked that way? why is that?
Comment 11 Jiri Prox 2016-02-29 11:23:15 UTC
so the jar is ok, it is exactly how it should work. 
I guess the problem is how the java is installed on your system. 
At first I'd check java version, you can type java --version to find out which version is actually used.
Comment 12 EddieDominguez 2016-02-29 20:36:35 UTC
I don't think I understand you. No version of what you said that I tried yielded any resault. Could you give me an example of how to type this? (for instance my jar file is C:\HelloWorld\dist\HelloWorld.jar so would I type after getting to C:\HelloWorld\dist\
java -jar HelloWorld.jar --version?
Comment 13 Jiri Prox 2016-02-29 23:44:24 UTC
just type 
  java -version

to command line. Not need to have a jar. This will print out the version of actual Java, 

then please check in the Tools -> Java Platform which version of java does the IDE use.


The output of command should be something like:
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
Comment 14 EddieDominguez 2016-03-01 15:54:30 UTC
Created attachment 158698 [details]
the java version both in netbeans and in cmd

ok, see the screenshot, seems the same to me
Comment 15 EddieDominguez 2016-03-15 09:33:59 UTC
Still not working. No other ideas? was this closed? i didn't mean it to be. the problem still persists
Comment 16 Jiri Prox 2016-03-17 12:05:04 UTC
The issue is closed since the problem is not in Netbeans itself. The jar is created correctly. The problem is in java integration into your OS