Hello,

I have build my application and now that I am trying to run the jar file by double clicking on it nothing happens.
I tried to access it from my terminal(mac OS) using this line:

java -jar "C:\Users\Me\NetBeansProjects\BS1\dist\BS1.jar"

But get the following error:
Unable to access jarfile

Can anyone help me?

I have set the main class.

Recommended Answers

All 12 Replies

Are you using Eclipse? Or did you make the Jar in the compiler? I know in Eclipse there are options in the build wizard, be sure you select runnable jar file.

No I am using netbeans. I clicked on clean and build

this might be part of it.
also: did you set your environment settings in your OS correctly? if you haven't even if you have a valid jar, clicking on it won't make it start.

No, I can only export to zip in netbeans. It does not solve my problem.

What do you mean set the environment setting correctly? Could you please clarify?

Thanks

you'll need to let your os know where to find the jre. as long as you're running your app in your IDE, no problem, but if you try to run an app or jar without an IDE, and your OS doesn't know where to find your jre, it won't run.

I beg to differ stuiltuske, because what London-G is saying is that the OS is failing to ACCESS the file, although if you insist....

London-G go to Advanced System Settings, and Select "Advanced" tab, and then select "Environment Variables", then select "PATH", in the second section, and add the path for your java.exe....

Personally i would ask the first question of if it is running from Netbeans....

edensigauke: yes, you are right, but I was also trying to provide a possible answer for this part of the original post:

I have build my application and now that I am trying to run the jar file by double clicking on it nothing happens.

which might be caused by the classpath that isn't set.

edensigauke I don't have advanced system settings in my mac. Is there another way to do that? I tried using the terminal but no luck so far.

I have a similar problem.
I used to be able to run .jar without any problems, but ever since I installed the Nokia PC suite, I can't run my .jar-s.
The suite automatically associated itself with the .jar-s, so I re-associated them with javaw.exe (found in C:\Program files (x86)\Java\jre7\bin\javaw.exe).
That did not help, as now when I double click, all I get is a split second of that windows loading circle on my cursor and my PC is like "Meh, like I care."

(Nothing happens.)

PS
Running Windows 7 Ultimate 64 bit.

EDIT:
I can perfectly run it through CMD (java -jar <filename>.jar).

Solved! I had the main class wrong.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.