Bug 33835 - NB3.5RC2 fails to load ANTLR jar (classpath)
NB3.5RC2 fails to load ANTLR jar (classpath)
Product: projects
Classification: Unclassified
Component: Ant
PC Windows ME/2000
: P3 (vote)
: 6.x
Assigned To: Jesse Glick
Depends on:
  Show dependency treegraph
Reported: 2003-05-22 14:44 UTC by oneway
Modified: 2007-10-09 18:33 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT


Note You need to log in before you can comment on or make changes to this bug.
Description oneway 2003-05-22 14:44:17 UTC
Project build (Ant build file) fails when
attempting to execute it from NB3.5 RC2. Works
fine in NB 3.4.1

Respective output as follows:
NB 3.5 RC2

-->!!! The antlr_272.jar file is in C:\Program
Files\NetBeans IDE
3.5rc2\modules\patches\org-apache-tools-ant-module !!!

from path as it doesn't exist
from path as it doesn't exist
Execute:Java13CommandLauncher: Executing 'java'
with arguments:
Exception in thread "main" 
src\ant\build.xml [83] ANTLR returned: 1

Execute:Java13CommandLauncher: Executing 'java'
with arguments:
'C:\Program Files\NetBeans
The ' characters around the executable and
arguments are
not part of the command.
ANTLR Parser Generator   Version 2.7.2   1989-2003
Comment 1 Jesse Glick 2003-05-22 15:05:41 UTC
It is a bug in Ant, which is already fixed in dev versions ("1.6 beta"):


NetBeans (correctly) constructs class loader resource URLs which
escape ' ' as "%20". The <antlr> task from Ant 1.5.x assumes it can
just use String.substring to translate a jar:file: URL to a File,
which is incorrect. Ant dev sources are more careful with URL <-> File

Workaround should be to install NetBeans in a directory that does not
contain any spaces.

Comment 2 Patrick Keegan 2003-05-22 16:03:15 UTC
proposed relnote:
Some Ant tasks fail when trying to load files. This occurs if the IDE
is installed in a directory that has spaces in its name.
Workaround: Move the IDE to a directory that does not contain spaces
in the name. 
Comment 3 Jesse Glick 2003-05-22 17:34:45 UTC
Sounds OK. BTW I do not know if the behavior is JDK-specific (i.e. 1.3
vs. 1.4). Dusan - would be helpful to investigate the exact tasks that
are affected, effect of JDK, etc. and provide more detailed release
notes. Also check if NB 3.4.1 with the Ant 1.5.1 module exhibits the
same behavior, or if only NB 3.5 has this problem - i.e. if there is
some interaction from the way the NB core constructs resource
(jar:file:...!/...) URLs, which on JDK 1.4 should use
File.toURI().toURL() but on JDK 1.3 uses a hackier system since
nothing better is available.
Comment 4 oneway 2003-05-22 18:47:11 UTC
The issue was reported for both NB341 and NB35 against:
java version "1.4.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)

It does work if NB is installed in dir without spaces.

Comment 5 Patrick Keegan 2004-03-03 23:06:57 UTC
still worth release noting, I suppose?
Comment 6 Jesse Glick 2004-03-04 04:16:40 UTC
Don't think so. According to my previous evaluation (don't remember
details now), it no longer applies to Ant 1.6.x, and NB 3.6 is now
shipping 1.6.x.
Comment 7 oneway 2004-03-23 20:24:17 UTC

The classpath was defined in the build.xml but, as one can see, it
does not get passed to the antlr (besides, ANTLR task does not have a
classpath property anyway).

Tried copying the antlr.jar into "lib", "pathches", etc directories
but  it did not help. Can't build with NB3.6.rc1.


Execute:Java13CommandLauncher: Executing 'C:\Program
Files\Sun\j2sdk1.4.2\jre\bin\java.exe' with arguments:

The ' characters around the executable and arguments are
not part of the command.
java.lang.NoClassDefFoundError: antlr/Tool
Exception in thread "main"

\build.xml [85] ANTLR returned: 1
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:301)
        at org.apache.tools.ant.Target.performTasks(Target.java:328)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
Comment 8 Jesse Glick 2004-03-24 12:19:04 UTC
lib, patches, etc. directories are not used by Ant in NB 3.6. You can
configure extra JARs to add to Ant's internal classpath in the Options
dialog, as is explained in the online help and FAQ for the Ant module.

Anyway the <antlr> task does accept a <classpath> as far as I can
tell, which should presumably contain antlr.jar.

I cannot work further on this without steps to reproduce from scratch,
including at least a build script. First you need to confirm that the
same script works correctly when run from command-line Ant (if not, it
is a bug in Ant that should be filed on ant.apache.org). Specifically
check whether putting antlr.jar in a directory containing spaces
works, i.e. whether the problem is the location of antlr.jar or of
Comment 9 oneway 2004-03-24 13:21:04 UTC
It appears you're right about the classpath property of the ANTLR
task. Tried it with 3.6.rc1, it appears to work. Closing the issue. Thanks
Comment 10 Marian Mirilovic 2005-07-12 09:41:33 UTC
Comment 11 gaganc 2006-09-10 08:49:02 UTC
This Issue is very much alive with NetBeans 5.0!

OS : Windows XP SP2
JDK : 1.5 Update 8
NetBeans : 5.0

Netbeans is installed in its default location ("Program Files\Netbeans 5.0"). I
am trying to build a project whose ant build uses ANTLR task. The project builds
without any problems from command line, but the same build fails in NetBeans
with following messages:

java.lang.NoClassDefFoundError: antlr/Tool
Exception in thread "main" 
C:\project\build.xml:180: ANTLR returned: 1
BUILD FAILED (total time: 3 seconds)

So i uninstalled Netbeans and reinstalled it in a folder without any whitespace
in its name. After that the project builds successfully even in Netbeans!

Comment 12 Jesse Glick 2006-09-11 23:57:22 UTC
Generally wisest to install NB in a folder w/o spaces. I will take a look at it
again when I get a chance.
Comment 13 Jesse Glick 2007-10-09 18:33:31 UTC
I run a 6.0 dev build, 071005, using JDK 6 on Ubuntu, in an installation with a space ("/tmp/net beans") and just for
fun in a userdir "/tmp/user dir". I open:

<project default="x">
    <target name="x">
        <property name="nb_all" location="/space/src/nb_all"/>
        <delete file="${java.io.tmpdir}/CalcScanner.java"/> <!-- no up-to-date check please -->
        <antlr target="${nb_all}/lexer/demo/src/org/netbeans/modules/lexer/demo/antlr/Calc.g"
                <fileset dir="${nb_all}/lexer/external" includes="*.jar"/>

where /space/src/nb_all is a NB source checkout. I run the 'x' target using context menu in the editor. Works, same as
from the command line, and same as from an IDE with no spaces in its installation dir.

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo