Take the 2-minute tour ×

I am developing a BlackBerry Application with a number of class files in it; 16 java classes at the moment and they keep increasing as this App is complex with a lot of screen and features. I am working in Eclipse with the BlackBerry Java Plug-in. I am using BlackBerry JRE 6.0. I have recently started getting the following error:

Error: Cannot run program "jar": CreateProcess error=2, The system cannot find the file specified

I have Google for this error and many suggest this is caused by Java Environmental Variable path. However, I have checked and everything seems to be fine at my end regarding that. I have noticed that when the number of classes is increased or a class becomes more lengthy, this error occurs. I get rid of the error by reducing the number of classes in a project. I created separated projects dividing the classes between each and it compiled fine. So I can believe that there is no issue with the source code.

Can anyone guide how to overcome this error in a single project that contains several classes. Please help.

EDIT: I came across the following on BlackBerry Support Forums:

"I think the most common reason for this (assuming that you have the JDK installed) is a large number of files in the project, and/or a project directory that is very far from the root.

The issue is that the RAPC compiler calls the JAR utility, building a command line that consists of all the class files in the application. If the command line length exceeds the maximum length allowed by the system, you will get this error."

How to work around this IF this is whats causing it.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

I was lucky to resolve this error. This link has been very helpful from BlackBerry Support Forums. For anyone else facing the same issue, the following steps resolved my issue:

  1. Right Click My Computer. Go To Properties.
  2. Click Advanced System Settings.
  3. Click Environment Variable
  4. Highlight PATH and click Edit. Add C:\Program Files (x86)\Java\jdk1.6.0_26\bin; to the start of the PATH.

Step 4 adds the java jar file to the PATH variable and adds it closer to the root. Adding closer to the root is helpful when compiling a project with several classes.

share|improve this answer
add comment

As the error says Cannot run program "jar" under Windows that means it cannot find the jar.exe executable file.

The problem, at least in my case, was that JAVA_HOME was pointing to the JRE on my computer (where there is no jar.exe in its "bin" folder) and not to the JDK where the jar.exe resides under its "bin" folder.

The solution was very simple - changed JAVA_HOME to point to the JDK root folder - in my case that was "C:\Program Files\Java\jdk1.7.0_15".

share|improve this answer
add comment

Your Answer


