Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #13318 > unrolled thread
| Started by | zyng <xsli2@yahoo.com> |
|---|---|
| First post | 2012-04-02 14:07 -0700 |
| Last post | 2012-04-03 16:29 -0700 |
| Articles | 9 — 4 participants |
Back to article view | Back to comp.lang.java.programmer
the classes in rt.jar cannot be found during ant build zyng <xsli2@yahoo.com> - 2012-04-02 14:07 -0700
Re: the classes in rt.jar cannot be found during ant build Lew <lewbloch@gmail.com> - 2012-04-02 15:53 -0700
Re: the classes in rt.jar cannot be found during ant build Roedy Green <see_website@mindprod.com.invalid> - 2012-04-02 16:00 -0700
Re: the classes in rt.jar cannot be found during ant build Arne Vajhøj <arne@vajhoej.dk> - 2012-04-02 19:44 -0400
Re: the classes in rt.jar cannot be found during ant build zyng <xsli2@yahoo.com> - 2012-04-02 17:16 -0700
Re: the classes in rt.jar cannot be found during ant build Arne Vajhøj <arne@vajhoej.dk> - 2012-04-02 20:53 -0400
Re: the classes in rt.jar cannot be found during ant build Roedy Green <see_website@mindprod.com.invalid> - 2012-04-03 10:49 -0700
Re: the classes in rt.jar cannot be found during ant build Arne Vajhøj <arne@vajhoej.dk> - 2012-04-03 19:15 -0400
Re: the classes in rt.jar cannot be found during ant build Roedy Green <see_website@mindprod.com.invalid> - 2012-04-03 16:29 -0700
| From | zyng <xsli2@yahoo.com> |
|---|---|
| Date | 2012-04-02 14:07 -0700 |
| Subject | the classes in rt.jar cannot be found during ant build |
| Message-ID | <21704562.1053.1333400837411.JavaMail.geo-discussion-forums@ynlt15> |
Hi,
In my build.xml,
<property environment="env"/>
...
<path id="project.classpath">
<fileset dir="${env.JAVA_HOME}">
<include name="jre/lib/rt.jar"/>
</fileset>
...
The environment variable JAVA_HOME has been set to: C:\Program Files\Java\jdk1.6.0_24
When I run it, those classes inside rt.jar cannot be found. I have print out, using echo, the classpath and rt.jar is included in the classpath.
I don't understand why the classes in rt.jar cannot be reached by javac.
Thank you very much.
[toc] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-04-02 15:53 -0700 |
| Message-ID | <29434054.1356.1333407212535.JavaMail.geo-discussion-forums@pbcvg9> |
| In reply to | #13318 |
zyng wrote:
> In my build.xml,
> <property environment="env"/>
> ...
> <path id="project.classpath">
> <fileset dir="${env.JAVA_HOME}">
> <include name="jre/lib/rt.jar"/>
> </fileset>
> ...
>
> The environment variable JAVA_HOME has been set to: C:\Program Files\Java\jdk1.6.0_24
>
> When I run it, those classes inside rt.jar cannot be found. I have print out, using echo, the classpath and rt.jar is included in the classpath.
>
> I don't understand why the classes in rt.jar cannot be reached by javac.
You don't give a complete example, for which you should follow the advice given here:
http://sscce.org/
Did you use a "<classpath refid='...'>" element or "classpathrefid='...'" attribute to the "<javac>" element that refers to your path id?
You should not include rt.jar in a regular classpath anyway. That's wrong. It's a bootclasspath JAR. In fact, you shouldn't have to refer to it explicitly at all unless you're cross-compiling between Java versions.
Give us an SSCCE.
--
Lew
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-04-02 16:00 -0700 |
| Message-ID | <nobkn719a2a7qudguhi2913bgrn01u4fjm@4ax.com> |
| In reply to | #13318 |
On Mon, 2 Apr 2012 14:07:17 -0700 (PDT), zyng <xsli2@yahoo.com> wrote,
quoted or indirectly quoted someone who said :
> <path id="project.classpath">
> <fileset dir="${env.JAVA_HOME}">
> <include name="jre/lib/rt.jar"/>
> </fileset>
Why would you do this? Javac is a built-in ant task. It finds files
in rt.jar all by itself.
<javac source="1.6" target="1.6" srcdir="com/mindprod/replicator"
sourcepath="${basedir}" classpath="${basedir}" debug="on"
includeAntRuntime="false">
--
Roedy Green Canadian Mind Products
http://mindprod.com
When you were a child, if you did your own experiment
to see if it was better to put to cocoa into your cup first
or the hot milk first, then you likely have the programmer gene..
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2012-04-02 19:44 -0400 |
| Message-ID | <4f7a39d0$0$295$14726298@news.sunsite.dk> |
| In reply to | #13318 |
On 4/2/2012 5:07 PM, zyng wrote:
> In my build.xml,
> <property environment="env"/>
> ...
> <path id="project.classpath">
> <fileset dir="${env.JAVA_HOME}">
> <include name="jre/lib/rt.jar"/>
> </fileset>
> ...
>
> The environment variable JAVA_HOME has been set to: C:\Program Files\Java\jdk1.6.0_24
>
> When I run it, those classes inside rt.jar cannot be found. I have print out, using echo, the classpath and rt.jar is included in the classpath.
>
> I don't understand why the classes in rt.jar cannot be reached by javac.
You should not need to specify rt.jar like that - actually you
should not specify rt.jar like that.
So how does you javac task look like and what errors are you getting?
Arne
[toc] | [prev] | [next] | [standalone]
| From | zyng <xsli2@yahoo.com> |
|---|---|
| Date | 2012-04-02 17:16 -0700 |
| Message-ID | <21217552.0.1333412199636.JavaMail.geo-discussion-forums@ynfo5> |
| In reply to | #13318 |
Below is a more completed build.xml. The error message
compile:
[javac] C:\my_work\build.xml:47: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to fals
for repeatable builds
[javac] Compiling 407 source files to C:\my_work\build
[javac] C:\my_work\src\abc\efg\xml\MyXmlUtils.java:27: package com.sun.xml.internal.fastinfoset.stax does not exist
[javac] import com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser;
[javac] ^
[javac] C:\my_work\src\abc\efg\xml\MyXmlUtils.java:28: package com.sun.xml.internal.fastinfoset.stax does not exist
[javac] import com.sun.xml.internal.fastinfoset.stax.StAXDocumentSerializer;
[javac] ^
[javac] C:\my_work\src\abc\efg\xml\MyXmlUtils.java:29: package com.sun.xml.internal.txw2.output does not exist
...
Those packages are located inside rt.jar. (I use Eclipse and I include rt.jar in the project property, so there is no compiling error in Eclipse).
Another observation (only happens in my office computer, not in my home computer) confuses me is that: when I copy rt.jar to rt2.jar which locates in the same directory(C:\Program Files\Java\jdk1.6.0_24\jre\lib) and modify build.xml a bit:
<fileset dir="${env.JAVA_HOME}">
<include name="jre/lib/rt2.jar"/>
</fileset>
Then ant works! Very confusing. I just re-tested this observation in my home computer and it does not work -- same error message. But this approach does work in my office computer.
<project name="myproject" default="compile" basedir=".">
<property environment="env"/>
<property name="build.dir" location="build"/>
<property name="libs.dir" location="../libs"/>
<property name="externals.dir" location="${libs.dir}/external"/>
<property name="install.dir" location="${libs.dir}/installed"/>
<path id="project.classpath">
<fileset dir="${env.JAVA_HOME}">
<include name="jre/lib/rt.jar"/>
</fileset>
<pathelement location="${build.dir}"/>
<fileset dir="${externals.dir}">
<include name="abc.jar"/>
<include name="xyz.jar"/>
<include name="junit.jar"/>
</fileset>
</path>
<target name="compile">
<javac srcdir="${src.dir}" destdir="${build.dir}" compiler="modern" fork="yes" debug="on">
<classpath refid="project.classpath"/>
<compilerarg value="-Xlint"/>
</javac>
</target>
</project>
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2012-04-02 20:53 -0400 |
| Message-ID | <4f7a4a06$0$287$14726298@news.sunsite.dk> |
| In reply to | #13335 |
On 4/2/2012 8:16 PM, zyng wrote:
> Below is a more completed build.xml. The error message
>
> compile:
> [javac] C:\my_work\build.xml:47: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to fals
> for repeatable builds
> [javac] Compiling 407 source files to C:\my_work\build
> [javac] C:\my_work\src\abc\efg\xml\MyXmlUtils.java:27: package com.sun.xml.internal.fastinfoset.stax does not exist
> [javac] import com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser;
> [javac] ^
> [javac] C:\my_work\src\abc\efg\xml\MyXmlUtils.java:28: package com.sun.xml.internal.fastinfoset.stax does not exist
> [javac] import com.sun.xml.internal.fastinfoset.stax.StAXDocumentSerializer;
> [javac] ^
> [javac] C:\my_work\src\abc\efg\xml\MyXmlUtils.java:29: package com.sun.xml.internal.txw2.output does not exist
> ...
>
> Those packages are located inside rt.jar. (I use Eclipse and I include rt.jar in the project property, so there is no compiling error in Eclipse).
Those packages are not intended to be used in your code.
You should use the documented API's.
> Another observation (only happens in my office computer, not in my home computer) confuses me is that: when I copy rt.jar to rt2.jar which locates in the same directory(C:\Program Files\Java\jdk1.6.0_24\jre\lib) and modify build.xml a bit:
> <fileset dir="${env.JAVA_HOME}">
> <include name="jre/lib/rt2.jar"/>
> </fileset>
> Then ant works! Very confusing. I just re-tested this observation in my home computer and it does not work -- same error message. But this approach does work in my office computer.
>
> <project name="myproject" default="compile" basedir=".">
> <property environment="env"/>
> <property name="build.dir" location="build"/>
> <property name="libs.dir" location="../libs"/>
> <property name="externals.dir" location="${libs.dir}/external"/>
> <property name="install.dir" location="${libs.dir}/installed"/>
>
> <path id="project.classpath">
> <fileset dir="${env.JAVA_HOME}">
> <include name="jre/lib/rt.jar"/>
> </fileset>
> <pathelement location="${build.dir}"/>
> <fileset dir="${externals.dir}">
> <include name="abc.jar"/>
> <include name="xyz.jar"/>
> <include name="junit.jar"/>
> </fileset>
> </path>
>
> <target name="compile">
> <javac srcdir="${src.dir}" destdir="${build.dir}" compiler="modern" fork="yes" debug="on">
> <classpath refid="project.classpath"/>
> <compilerarg value="-Xlint"/>
> </javac>
> </target>
> </project>
You should not explicitly ref rt.jar!
Arne
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-04-03 10:49 -0700 |
| Message-ID | <ba6ln79kgkd395anb8jo9ctpgkrvp1lv72@4ax.com> |
| In reply to | #13335 |
On Mon, 2 Apr 2012 17:16:39 -0700 (PDT), zyng <xsli2@yahoo.com> wrote, quoted or indirectly quoted someone who said : >Below is a more completed build.xml. The error message see http://mindprod.com/jgloss/jdk.html I suspect you have not fully installed the JDK. javac.exe needs to be on the path, for example. -- Roedy Green Canadian Mind Products http://mindprod.com When you were a child, if you did your own experiment to see if it was better to put to cocoa into your cup first or the hot milk first, then you likely have the programmer gene..
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2012-04-03 19:15 -0400 |
| Message-ID | <4f7b8484$0$290$14726298@news.sunsite.dk> |
| In reply to | #13351 |
On 4/3/2012 1:49 PM, Roedy Green wrote:
> On Mon, 2 Apr 2012 17:16:39 -0700 (PDT), zyng<xsli2@yahoo.com> wrote,
> quoted or indirectly quoted someone who said :
>
>> Below is a more completed build.xml. The error message
>
> see http://mindprod.com/jgloss/jdk.html
> I suspect you have not fully installed the JDK.
> javac.exe needs to be on the path, for example.
With the error messages:
<quote>
compile:
[javac] C:\my_work\build.xml:47: warning: 'includeantruntime' was
not set, defaulting to build.sysclasspath=last; set to fals
for repeatable builds
[javac] Compiling 407 source files to C:\my_work\build
[javac] C:\my_work\src\abc\efg\xml\MyXmlUtils.java:27: package
com.sun.xml.internal.fastinfoset.stax does not exist
[javac] import
com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser;
[javac] ^
[javac] C:\my_work\src\abc\efg\xml\MyXmlUtils.java:28: package
com.sun.xml.internal.fastinfoset.stax does not exist
[javac] import
com.sun.xml.internal.fastinfoset.stax.StAXDocumentSerializer;
[javac] ^
[javac] C:\my_work\src\abc\efg\xml\MyXmlUtils.java:29: package
com.sun.xml.internal.txw2.output does not exist
</quote>
then javac.exe not being in the path causing the problems seems
as likely as 2+2=7.
Arne
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-04-03 16:29 -0700 |
| Message-ID | <1u1nn7557ovpj0i8j0d21jrv306fiu0gpu@4ax.com> |
| In reply to | #13335 |
On Mon, 2 Apr 2012 17:16:39 -0700 (PDT), zyng <xsli2@yahoo.com> wrote, quoted or indirectly quoted someone who said : >Below is a more completed build.xml. The error message see http://mindprod.com/jgloss/jdk.html I suspect you have not fully installed the JDK. javac.exe needs to be on the path, for example. -- Roedy Green Canadian Mind Products http://mindprod.com When you were a child, if you did your own experiment to see if it was better to put to cocoa into your cup first or the hot milk first, then you likely have the programmer gene..
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web