Error Reading File

up to a few days ago my application worked like a treat. ive spend the last fews days create .EXE .JNLP files, and writing README files for it.

Now today - just for one last clean and build before I package it, im getting this "cannot compile stylesheet" error.

I havnt changed anything to brake it but for some reason it isnt working anymore...

ive build a simple RSS feed based on swing components.

I have my XSL file in a folder called "etc"

here is a run  down of my structure:  

newsreader
     |----build
     |----docs
     |----dist
     |----etc
     |----src
     |----test

the actual error im getting is:

run:
ERROR:  'C:\newsreader\build\classes\etc\rss.xsl (The system cannot find the path specified)'
FATAL ERROR:  'Could not compile stylesheet'
BUILD SUCCESSFUL (total time: 4 seconds)


how i read my file in RSSContentPane.java:

try {
            File file = new File( "etc/rss.xsl" ) ;
            this.rssSource = new URL( this.selectedRSSFeed ) ;
            this.xslSource = file.toURL() ;
            this.writer = new StringWriter() ;
            this.rssTransformer = new RSSTransformer() ;
            this.rssTransformer.process( this.rssSource, this.xslSource, this.writer ) ;
            this.setText( this.writer.getBuffer().toString() ) ;
            this.html.setCaretPosition( 0 ) ;
        } catch( MalformedURLException e ) {
            JOptionPane.showMessageDialog( null, e.toString(), "News Reader (RSS)", JOptionPane.ERROR_MESSAGE ) ;
            System.exit( 0 ) ;
        } catch ( TransformerException e ) {
            JOptionPane.showMessageDialog( null, e.toString(), "News Reader (RSS)", JOptionPane.ERROR_MESSAGE ) ;
        } catch ( IOException e ) {
            JOptionPane.showMessageDialog( null, e.toString(), "News Reader (RSS)", JOptionPane.ERROR_MESSAGE ) ;
            System.exit( 0 ) ;
        }


transformer.java code:

public class RSSTransformer {
    private TransformerFactory factory;
   
    /** Creates a new instance of RSSTransformer */
    public RSSTransformer() {
        factory = TransformerFactory.newInstance();
    }
   
    public void process( URL url, URL xsl, Writer out ) throws TransformerException {
        try {
            Templates template = factory.newTemplates( new StreamSource( xsl.toExternalForm() ) );
            Transformer transformer = template.newTransformer();
            transformer.transform( new StreamSource( url.toExternalForm() ), new StreamResult( out ) );
        } catch ( TransformerConfigurationException e ) {
            JOptionPane.showMessageDialog( null, "Your RSS source was not valid" , "News Reader (RSS)", JOptionPane.ERROR_MESSAGE );
        } catch ( TransformerException e ) {
            JOptionPane.showMessageDialog( null, "Your RSS source was not valid" , "News Reader (RSS)", JOptionPane.ERROR_MESSAGE );
        }
    }
}


if you need more code please ask...

ps. this is urgent!



LVL 16
ellandrdAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
>>File file = new File( "etc/rss.xsl" ) ;

is wrong for where your program is being run from. Run from newsreader
0
ellandrdAuthor Commented:
so my path is wrong yes?
0
CEHJCommented:
Other options:

a. use an absolute path
b. use a URL and getResource(), specifying correctly in relation to your classpath/packages
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

ellandrdAuthor Commented:
cool ok...
0
ellandrdAuthor Commented:
see using Absolute path, where would i start it from? newsreader or my c:\?
0
objectsCommented:
how are you running it?
0
objectsCommented:
if you add your etc directory to your class path you can use the following:

this.xslSource = getClass().getResource("rss.xsl");

you then don't need to create that file instance at all
0
ellandrdAuthor Commented:
Standalone application - im planning of distributing it by webstart...
0
objectsCommented:
> see using Absolute path, where would i start it from? newsreader or my c:\?

problem with absolute path is that if you always have to have it installed in the same locatiuon
0
ellandrdAuthor Commented:
>>if you add your etc directory to your class path....

see when people do this, will this be for the whole of netbeans or just this project?
0
objectsCommented:
> Standalone application - im planning of distributing it by webstart...

then add the etc directory into your jar, and use:


this.xslSource = getClass().getResource("/etc/rss.xsl");
0
CEHJCommented:
If using Webstart, option b. in my comment is best
0
ellandrdAuthor Commented:
>>then add the etc directory into your jar, and use:

not sure how i do this?

do i have to change my build.xml?  i have already customised this build.xml...
0
ellandrdAuthor Commented:
actually on saying that, the only thing ive changed since it has been all working is my build.xml file...

what to see it?
0
CEHJCommented:
>>do i have to change my build.xml?  

Not sure, but if you have one, i'm surprised your resources are not already there. Please post output of

jar tf yourjar.jar
0
CEHJCommented:
>>what to see it?

I assume you mean *want* to see it. Not yet ;-)
0
objectsCommented:
to use a relative path you need to set the base directory in your build file correctly

but if you load it from the jar that shouldn't be a problem.

When it is installed were you planning on copying the xsl to the users disk, or load it from the jar?

If from disk then the other option is to put it in a known location such as the users home directory
0
ellandrdAuthor Commented:
i get "jar" not recognised
0
ellandrdAuthor Commented:
objects

i want to load it from the jar... there will be no copying of files to users disk...  

it will be either an jar file wrapped in .exe or an jnlp file for webstart...
0
objectsCommented:
the build is using a base diretcory of:

C:\newsreader\build\classes\

it should be:

C:\newsreader
0
objectsCommented:
> i want to load it from the jar... there will be no copying of files to users disk...  

then do as I suggested above :)
0
objectsCommented:
the code you have currently won't work with the xsl in the jar, you need to change it
0
ellandrdAuthor Commented:
im not sure:

here is how is set up some properties in my build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="NewsReader" default="run" basedir=".">
   
    <import file="nbproject/build-impl.xml"/>

    <!-- define some useful properties -->
    <property name="project.build" location="${basedir}/build/classes"/>
    <property name="project.source" location="${basedir}/src/"/>
    <property name="project.etc" location="${basedir}/etc/"/>
    <property name="project.documentation" location="${basedir}/doc/"/>
    <property name="project.main.class" value="u0207372.NRStandalone"/>
 
...


do you mean just have:

<property name="project.build" location="${basedir}/build "/>

?
0
objectsCommented:
moving the xsl into your jar will mean you don't need to change the build as you will no longer need the line that is giving you the error
0
objectsCommented:
this:

            File file = new File( "etc/rss.xsl" ) ;
            this.rssSource = new URL( this.selectedRSSFeed ) ;
            this.xslSource = file.toURL() ;

becomes just:

            this.rssSource = new URL( this.selectedRSSFeed ) ;
            this.xslSource = getClass().getResource("/etc/rss.xsl");
0
ellandrdAuthor Commented:
ok but im not too sure how i add te xsl file or this etc folder into the jar file?
0
objectsCommented:
add the directory to the file list in your jar build target
0
CEHJCommented:
Please post the output of

jar tf yourjar.jar
0
ellandrdAuthor Commented:
>>Date: 03/23/2006 10:56AM GMT
0
CEHJCommented:
Oh, OK. You need to add %JAVA_HOME%\bin to your path
0
CEHJCommented:
(Creating the variable JAVA_HOME [the installation directory of your JDK] first if necessary)
0
objectsCommented:
theres no need to run jar :)
0
ellandrdAuthor Commented:
ok guys - the two of ye telling me to do different things isnt helping!

i want my application to run off a exe or jnlp - there will be no copying of files onto users disks.

CEHJ

i cant get jar to work...

Objects

>>add the directory to the file list in your jar build target

im stuck here with this...  i never added file list to jar so i dont know what im doing...

what ive got is:

<?xml version="1.0" encoding="UTF-8"?>
<project name="RSSReader" default="run" basedir=".">
   
    <import file="nbproject/build-impl.xml"/>

    <!-- define some useful properties -->
    <property name="project.build" location="${basedir}/build/classes"/>
    <property name="project.source" location="${basedir}/src/"/>
    <property name="project.etc" location="${basedir}/etc/"/>
    <property name="project.documentation" location="${basedir}/doc/"/>
    <property name="project.main.class" value="u0207372.NRStandalone"/>
 
    <!-- define a classpath and attach a reference to it -->
    <path id="project.classpath">
        <pathelement location="${project.build}"/>
    </path>
   
    <!-- compile the application -->
    <target name="build" description="--&gt; compile the application">
        <javac srcdir="${basedir}/src/" destdir="${project.build}" classpathref="project.classpath" debug="on">
        </javac>
    </target>
   
    <!-- run the application -->
    <target name="run" description="--&gt; run the application">
        <java classname="${project.main.class}" fork="true" classpath="project.classpath" dir="${basedir}/build/classes">
        </java>
    </target>
 ...
0
CEHJCommented:
>>i cant get jar to work...

That should be done - a Java developer should always be able to run jar ;-)

>>>>add the directory to the file list in your jar build target

It's already added
0
CEHJCommented:
xslSource = getResource("etc/rss.xsl" )  ;

Since it's already added, the above should work
0
CEHJCommented:
Sorry

xslSource = getResource("/etc/rss.xsl" )  ;
0
objectsCommented:
following covers the jar target

http://ant.apache.org/manual/CoreTasks/jar.html
0
ellandrdAuthor Commented:
method getResource not found?

0
objectsCommented:
in your case it would be something like:

<jar destfile="${basedir}/rssreader.jar">
    <fileset dir="${project.build}" />
    <fileset dir="${project.etc}"/>
</jar>

add that to your build target (or you can make it seperate if yuou want)
0
CEHJCommented:
Sorry - not quite awake

getClass().getResource(................................
0
objectsCommented:
> method getResource not found?

see what I suggested earlier.

using the above build it would be:

            this.xslSource = getClass().getResource("rss.xsl");
0
ellandrdAuthor Commented:
like this

<!-- compile the application -->
    <target name="build" description="--&gt; compile the application">
        <jar destfile="${basedir}/dist/rssreader.jar">
            <fileset dir="${project.build}" />
            <fileset dir="${project.etc}"/>
        </jar>
        <javac srcdir="${basedir}/src/" destdir="${project.build}" classpathref="project.classpath" debug="on">
        </javac>
    </target>

?

also this:

this.xslSource = this.getClass().getResource( "/etc/rss.xsl" )  ;

gives me a null pointer...

i have tired too:

this.xslSource = this.getClass().getResource( "etc/rss.xsl" )  ;

still null pointer...
0
CEHJCommented:
>>like this

No - you need to compile it before you jar it
0
objectsCommented:
see my comment above:

this.xslSource = this.getClass().getResource( "rss.xsl" )  ;

and move the builkding of jar, *after* the jjavac
0
ellandrdAuthor Commented:
still get null pointer!

<!-- compile the application -->
    <target name="build" description="--&gt; compile the application">
        <javac srcdir="${basedir}/src/" destdir="${project.build}" classpathref="project.classpath" debug="on">
        </javac>
        <jar destfile="${basedir}/rssreader.jar">
            <fileset dir="${project.build}" />
            <fileset dir="${project.etc}"/>
        </jar>
    </target>

in my RSSContentPane, ive got:

URL xslSource = getClass().getResource( "rss.xsl" )  ;
0
objectsCommented:
sorry, should have been:

URL xslSource = getClass().getResource( "/rss.xsl" )  ;
0
ellandrdAuthor Commented:
i'd love to say it working but im still getting this:

run:
Exception in thread "main" java.lang.NullPointerException
        at u0207372.gui.RSSContentPanel.updateRSSNews(RSSContentPanel.java:66)
        at u0207372.gui.RSSContentPanel.<init>(RSSContentPanel.java:52)
        at u0207372.NRStandalone.<init>(NRStandalone.java:27)
        at u0207372.NRStandalone.main(NRStandalone.java:46)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
0
ellandrdAuthor Commented:
see when i added these lines of code:

<!-- compile the application -->
    <target name="build" description="--&gt; compile the application">
        <javac srcdir="${basedir}/src/" destdir="${project.build}" classpathref="project.classpath" debug="on">
        </javac>
        <jar destfile="${basedir}/rssreader.jar">
            <fileset dir="${project.build}" />
            <fileset dir="${project.etc}"/>
        </jar>
    </target>

should this have created a rssreader.jar in the base dir?

because it dont!
0
objectsCommented:
forgot to change the run target :)
it needs to include the jar in the classpath instead of the classes onm disk

0
objectsCommented:
> should this have created a rssreader.jar in the base dir?

yes it should have, did u run the build target?
if so, what was the output?
0
objectsCommented:
       <java classname="${project.main.class}" fork="true" classpath="${basedir}/rssreader.jar" dir="${basedir}">
0
CEHJCommented:
>><fileset dir="${project.etc}"/>

Rather than the above, you'd be better with

<fileset dir="${basedir}"/>
   <!-- keep logical separation intact and include what's necessary -->
    <include name="etc/**" />
</fileset>
0
ellandrdAuthor Commented:
>>yes it should have, did u run the build target?
>>if so, what was the output?

build:
Building jar: C:\rssreader\rssreader.jar
BUILD SUCCESSFUL (total time: 0 seconds)

but not jar file though!

>>it needs to include the jar in the classpath instead of the classes onm disk

in here:

<path id="project.classpath">
        <pathelement location="${project.build}"/>
    </path>


0
objectsCommented:
see my comment above
0
ellandrdAuthor Commented:
ok objects ive added that line you gave me in here:

<!-- run the application -->
    <target name="run" description="--&gt; run the application">
        <java classname="${project.main.class}" fork="true" classpath="${basedir}/rssreader.jar" dir="${basedir}">
        </java>
    </target>

im sorry after i refreshed my folder, the jar appeared... in the base dir
0
ellandrdAuthor Commented:
im still getting this null pointer...

dont know what ive got wrong?

URL xslSource = getClass().getResource( "/rss.xsl" )  ;


in my build.xml file i ahve this:

<?xml version="1.0" encoding="UTF-8"?>
<project name="RSSReader" default="run" basedir=".">
   
    <import file="nbproject/build-impl.xml"/>

    <!-- define some useful properties -->
    <property name="project.build" location="${basedir}/build/classes"/>
    <property name="project.source" location="${basedir}/src/"/>
    <property name="project.etc" location="${basedir}/etc/"/>
    <property name="project.documentation" location="${basedir}/doc/"/>
    <property name="project.main.class" value="u0207372.NRStandalone"/>
 
    <!-- define a classpath and attach a reference to it -->
    <path id="project.classpath">
        <pathelement location="${project.build}"/>
    </path>
   
    <!-- compile the application -->
    <target name="build" description="--&gt; compile the application">
        <javac srcdir="${basedir}/src/" destdir="${project.build}" classpathref="project.classpath" debug="on">
        </javac>
        <jar destfile="${basedir}/rssreader.jar">
            <fileset dir="${project.build}" />
            <fileset dir="${project.etc}" includes="**/*.xsl"/>
        </jar>
    </target>
   
    <!-- run the application -->
    <target name="run" description="--&gt; run the application">
        <java classname="${project.main.class}" fork="true" classpath="${basedir}/rssreader.jar" dir="${basedir}/build/classes" />
    </target>

.....
0
ellandrdAuthor Commented:
i hate when people dont reply ;-)
0
CEHJCommented:
List the jar

jar tf rssreader.jar

, using the full path to jar.exe if necessary
0
ellandrdAuthor Commented:
the output is:

META-INF
u0207372
rss.xsl
0
ellandrdAuthor Commented:
so the rss.xsl is been added the the jar, but after that i dont know what im doing esp playing around with the build.xml...

0
CEHJCommented:
There's no application in there! - Just two directories and your xsl file
0
ellandrdAuthor Commented:
what do you mean?

what is mean to be in there?
0
CEHJCommented:
All your classes. Can you post the output of

dir build/classes /s/b
0
CEHJCommented:
Sorry - that was meant to be

All your classes. Can you post the output of

dir build\classes /s/b
0
ellandrdAuthor Commented:
it contains all my .class files
0
CEHJCommented:
Please post output
0
ellandrdAuthor Commented:
you still there? when you go offline tell me...
0
CEHJCommented:
Yes
0
ellandrdAuthor Commented:
just so you know im getting nowhere!

ive just spend last 2 hours getting nowhere..

lets just get this working and no messing about - e.g 1 liner comments - ive never played about the build.xml before so therefore ive not got a clue what im doing!
0
CEHJCommented:
Going off for few minutes
0
CEHJCommented:
*You* must do what i ask then - so far you haven't ;-) Back soon
0
ellandrdAuthor Commented:
ok lets start from stratch.

here is my build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="NewsReader" default="build" basedir=".">
   
    <import file="nbproject/build-impl.xml"/>

    <!-- define some useful properties -->
    <property name="project.build" location="${basedir}/build/classes"/>
    <property name="project.source" location="${basedir}/src/"/>
    <property name="project.etc" location="${basedir}/etc/"/>
    <property name="project.documentation" location="${basedir}/doc/"/>
    <property name="project.main.class" value="u0207372.NRStandalone"/>
 
    <path id="project.classpath">
        <!--pathelement location="${project.build}"/-->
        <pathelement location="${basedir}/dist/newsreader.jar"/>
    </path>

    <!-- build the application -->
    <target name="build" description="--&gt; compile the application">
        <javac srcdir="${basedir}/src" destdir="${project.build}" classpathref="project.classpath" debug="on">
        </javac>
        <jar destfile="${basedir}/dist/newsreader.jar" basedir="${project.build}" update="false">
            <fileset dir="${project.etc}"/>
            <manifest>
                <attribute name="Built-By" value="u0207372"/>
                <attribute name="Main-Class" value="${project.main.class}"/>
                <attribute name="Specification-Title" value="${ant.project.name}"/>
            </manifest>
        </jar>
    </target>

    <!-- run the application -->
    <target name="run" depends="build" description="--&gt; run the application">
        <java classname="${project.main.class}" classpathref="project.classpath" fork="true">
        </java>
        <jar destfile="${basedir}/dist/newsreader.jar" basedir="${project.build}" update="false">
            <fileset dir="${project.etc}"/>
            <manifest>
                <attribute name="Built-By" value="u0207372"/>
                <attribute name="Main-Class" value="${project.main.class}"/>
                <attribute name="Specification-Title" value="${ant.project.name}"/>
            </manifest>
        </jar>
    </target>
   
    <!-- clean the application -->
    <target name="clean" description="--&gt; clean">
        <delete>
            <fileset dir="${project.build}" includes="**.*"/>
        </delete>
    </target>

</project>

when i build i get the XSL file and build/classess put into the JAR file.

when i run i get:

build:
run:
Exception in thread "main" java.lang.NullPointerException
        at u0207372.RSSTransformer.process(RSSTransformer.java:30)
        at u0207372.gui.RSSContentPanel.updateRSSNews(RSSContentPanel.java:65)
        at u0207372.gui.RSSContentPanel.<init>(RSSContentPanel.java:52)
        at u0207372.NRStandalone.<init>(NRStandalone.java:27)
        at u0207372.NRStandalone.main(NRStandalone.java:46)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)

Now i know the XSL file is in the JAR as when i extend my JAR i can see it along with my u0207372/build/classes.

the u0207372/build/classes contains:

gui/RSSContentPane.class
gui/RSSInput.class
gui/RSSList.class
NRStandalone.class
RSSTransformer.class

in my RSSContentPane.java I have this:

URL xslSource = this.getClass().getResource( "/rss.xsl" )  ;

if you need anything else - just ask
0
CEHJCommented:
Is there a package specified in NRStandalone.java?
0
ellandrdAuthor Commented:
package u0207372 ;
0
ellandrdAuthor Commented:
is there a way we could copy all the etc folder into the jar file instead of just the rss.xsl?
0
CEHJCommented:
OK. Can you please copy and paste (i include the prompt below) the output of

C:\whatever\build\classes>dir /s/b

?
0
CEHJCommented:
>> is there a way we could copy all the etc folder into the jar file instead of just the rss.xsl?

Yes, i mentioned that earlier, but forget that for the moment - there seem to be more fundamental issues wrong
0
ellandrdAuthor Commented:
C:\newsreader\build\classes>dir /s/b
C:\newsreader\build\classes\u0207372
C:\newsreader\build\classes\u0207372\gui
C:\newsreader\build\classes\u0207372\NRStandalone.class
C:\newsreader\build\classes\u0207372\RSSTransformer.class
C:\newsreader\build\classes\u0207372\gui\RSSContentPanel.class
C:\newsreader\build\classes\u0207372\gui\RSSInput$1.class
C:\newsreader\build\classes\u0207372\gui\RSSInput.class
C:\newsreader\build\classes\u0207372\gui\RSSList$1.class
C:\newsreader\build\classes\u0207372\gui\RSSList.class
0
CEHJCommented:
OK - not as bad as i thought. BACK THE ORIGINAL UP and try the following. You'll need to load the xsl file as i originally mentioned (after my self-correction)

<?xml version="1.0" encoding="UTF-8"?>
<project name="RSSReader" default="run" basedir=".">
   
    <import file="nbproject/build-impl.xml"/>

    <!-- define some useful properties -->
    <property name="project.build" location="${basedir}/build/classes"/>
    <property name="project.source" location="${basedir}/src/"/>
    <property name="project.etc" location="${basedir}/etc/"/>
    <property name="project.documentation" location="${basedir}/doc/"/>
    <property name="project.main.class" value="u0207372.NRStandalone"/>
 
    <!-- define a classpath and attach a reference to it -->
    <path id="project.classpath">
        <pathelement location="${project.build}"/>
    </path>
   
    <!-- compile the application -->
    <target name="build" description="--&gt; compile the application">
        <javac srcdir="${basedir}/src/" destdir="${project.build}" classpathref="project.classpath" debug="on">
        </javac>
       
        <jar basedir="${basedir}" destfile="${basedir}/rssreader.jar">
            <manifest>
                <attribute name="Main-Class" value="${project.main.class}"/>
            </manifest>    

            <fileset dir="${project.build}">
                  <include name="**/*.class" />
            </fileset>
          
          <fileset dir="${basedir}"/>
               <!-- keep logical separation intact and include what's necessary -->
                <include name="etc/**/*.xsl" />
          </fileset>

        </jar>
    </target>
   
    <!-- run the application -->
    <target name="run" description="--&gt; run the application">
        <java classname="${project.main.class}" fork="true" classpath="${basedir}/rssreader.jar" dir="${basedir}/build/classes" />
    </target>
0
CEHJCommented:
The end of what i just posted is missing the closing </project> tag

Also, replace the java task with the following:

<java jar="rssreader.jar" fork="true" dir="${basedir}" />
0
ellandrdAuthor Commented:
>>You'll need to load the xsl file as i originally mentioned (after my self-correction)

as in: 03/23/2006 11:56AM GMT

0
ellandrdAuthor Commented:
>>Also, replace the java task with the following:
>><java jar="rssreader.jar" fork="true" dir="${basedir}" />

eh? lost
0
CEHJCommented:
As in http:Q_21785541.html#16267974

See my last correction too
0
CEHJCommented:
>>eh? lost

Use that instead of

  <java classname="${project.main.class}" fork="true" classpath="${basedir}/rssreader.jar" dir="${basedir}/build/classes" />
0
ellandrdAuthor Commented:
i get this:

build:
Building jar: C:\newsreader\dist\newsreader.jar
C:\newsreader\build.xml:23: A zip file cannot include itself
BUILD FAILED (total time: 1 second)


Now i have not added: <java jar="rssreader.jar" fork="true" dir="${basedir}" /> as i dont know where it goes...

0
CEHJCommented:
>>as i dont know where it goes...

It goes where i said - in place of where the previous java task was
0
ellandrdAuthor Commented:
run:
java.lang.NoClassDefFoundError: u0207372/NRStandalone
Exception in thread "main"
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
0
CEHJCommented:
jar tf rssreader.jar

output please
0
ellandrdAuthor Commented:
newsreader
META-INF
build
dist
doc
etc
nbproject
src
test
NewsReader.jnlp
applet.policy
build.xml
manifest.mf
readme.html
run.bat
0
CEHJCommented:
If that's really the jar listing again it's got nothing of interest in it. That doesn't look like it was produced with the build xml i've just given you. Better post the output of

type build.xml
0
ellandrdAuthor Commented:
C:\newsreader>type build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="RSSReader" default="run" basedir=".">

    <import file="nbproject/build-impl.xml"/>

    <!-- define some useful properties -->
    <property name="project.build" location="${basedir}/build/classes"/>
    <property name="project.source" location="${basedir}/src/"/>
    <property name="project.etc" location="${basedir}/etc/"/>
    <property name="project.documentation" location="${basedir}/doc/"/>
    <property name="project.main.class" value="u0207372.NRStandalone"/>

    <!-- define a classpath and attach a reference to it -->
    <path id="project.classpath">
        <pathelement location="${project.build}"/>
    </path>

    <!-- compile the application -->
    <target name="build" description="--&gt; compile the application">
        <javac srcdir="${basedir}/src/" destdir="${project.build}" classpathref=
"project.classpath" debug="on">
        </javac>

        <jar basedir="${basedir}" destfile="${basedir}/dist/newsreader.jar">
          <manifest>
              <attribute name="Main-Class" value="${project.main.class}"/>
          </manifest>

            <fileset dir="${project.build}">
                 <include name="**/*.class" />
            </fileset>

         <fileset dir="${basedir}">
              <include name="etc/**/*.xsl" />
         </fileset>

        </jar>
    </target>

    <!-- run the application -->
    <target name="run" description="--&gt; run the application">
        <java jar="${basedir}/dist/newsreader.jar" fork="true" dir="${basedir}/b
uild/classes" />

        <!--java classname="${project.main.class}" fork="true" classpath="${base
dir}/dist/newsreader.jar" dir="${basedir}/build/classes" /-->
    </target>
</project>
C:\newsreader>
0
CEHJCommented:
OK - looks like the output file has now changed, can you post the output of

jar tf dist\newsreader.jar
0
ellandrdAuthor Commented:


it working!!!!! yes - can eat now - havnt eaten since 6.30 dismorning...
0
ellandrdAuthor Commented:
kinda need to pull myself from outta this chair now...
cheers for the help..

just wanna do one more test before accepting....
0
ellandrdAuthor Commented:
ok ive tried to add my package target and sign-jar target and im getting this:

jarsigner: unable to sign jar: java.util.zip.ZipException: duplicate entry: etc/rss.xsl
C:\newsreader\build.xml:57: The following error occurred while executing this line:
C:\newsreader\build.xml:72: exec returned: 1
BUILD FAILED (total time: 0 seconds)


maybe i have it done wrong - i trying to have the same as what you had for build...


here is my code:

<!-- package the application -->
    <target name="package" depends="build" description="--&gt; create distribution">
        <jar destfile="NewsReaderApp.jar" basedir="${basedir}" update="false">
            <fileset dir="${basedir}">
                <include name="etc/**" />
            </fileset>
            <manifest>
                <attribute name="Built-By" value="u0207372"/>
                <attribute name="Main-Class" value="${project.main.class}"/>
                <attribute name="Specification-Title" value="${ant.project.name}"/>
            </manifest>
        </jar>
        <!-- Signing is normally only required for extended permissions
        and integrity checks. If not, delete the next line and the associated target. -->
        <antcall target="sign-jar">
        </antcall>
    </target>
   
    <!-- sign the application -->
    <target name="sign-jar">
        <!-- check if a keystore file is required -->
        <condition property="keystore.missing">
            <not>
                <available file="${basedir}/etc/u0207372Store">
                </available>
            </not>
        </condition>
        <antcall target="generate-keystore">
        </antcall>
        <signjar jar="NewsReaderApp.jar" keystore="${basedir}/etc/u0207372Store" alias="u0207372Sign" signedjar="SignedNewsReaderApp.jar" storepass="lqv78" keypass="lqv78" verbose="true">
        </signjar>
    </target>
   
    <!-- Generating a new keystore file -->
    <target name="generate-keystore" if="keystore.missing">
        <echo>***** Generating a new keystore file. *****</echo>
        <genkey alias="u0207372Sign" storepass="lqv78" verbose="true" keystore="${basedir}/etc/u0207372Store" keypass="lqv78" dname="CN=u0207372, OU=u0207372, O=Aberdeen, C=UK">
        </genkey>
    </target>
0
CEHJCommented:
With any luck you should be able to start that by double-clicking the jar
0
CEHJCommented:
>>jar="NewsReaderApp.jar"

But that isn't the jar is it?
0
ellandrdAuthor Commented:
its ok i fixed it...
0
ellandrdAuthor Commented:
see if i build it and try try build it again it wont let me.

but if i build it, then clean it -cleaning it does nothing...

    <!-- clean the application -->
    <target name="clean" description="--&gt; clean">
        <delete>
            <fileset dir="${basedir}/build/classes" includes="**.*"/>
        </delete>
    </target>
0
CEHJCommented:
I would normally do

<fileset dir="${basedir}/build/classes" includes="**/*.*"/>
0
CEHJCommented:
:-)
0
objectsCommented:
Sorry had to get some sleep, can you explain the split please.
The question was about reading the xsl which I helped you with with.
Fxing your build was a seperate issue and really should have been a seperate question.

0
objectsCommented:
and his earlier comment that you accepted is wrong:

> xslSource = getResource("/etc/rss.xsl" )  ;



0
CEHJCommented:
It isn't wrong ;-)
0
ellandrdAuthor Commented:
>>and his earlier comment that you accepted is wrong:
> xslSource = getResource("/etc/rss.xsl" )  ;

it worked.

I split the points as both of your comments had helped in the end - did you want me to award all points to you?  I split them as I though it wasnt fair to award CEHJ all 500 even though he spend hours helping me out, but so did you.  

Yes the question was about reading in my xsl file, but inorder to do so you suggested include it in the jar file so this lead to changing my build.xml file to include the xsl file... remember? (Date: 03/23/2006 10:50AM GMT) hence why the question lead more into changing my build.xml file.

Im sure you have been apart of many threads that have evolved off-topic while trying to solve the problem e.g the asker thinks its 1 thing, when it isnt and the thread changes course...

>>The question was about reading the xsl which I helped you with with.

And i award you some points for helping - i might have not selected the right comments but at least you got some credit for it... after all how many comments are in this thread?  it isnt easy to read back over them all and selected the best ones when you havent eaten in like 9 hours or have not moved from your chair...

in fact i lost a whole day work yesterday due to this issue and thanks to both of ye, I got it fixed, but at some expense.

ellandrd
0
ellandrdAuthor Commented:
p.s im not here to argue with people over some stupid points
0
objectsCommented:
> it worked.

it won't even compiled (as u yourself stated)
And the corrected version was copied from my previous comments.

> hence why the question lead more into changing my build.xml file.

which should have been a seperate question.
the solution to your problem required no change to your build script
as I \stated you just needed to include the xsl in your classpath

> Im sure you have been apart of many threads that have evolved off-topic while trying to solve the problem e.g the asker thinks its
> 1 thing, when it isnt and the thread changes course...

Yes, but I don't expect the points for it after someone else has alr3eaqdy answered the question.

> p.s im not here to argue with people over some stupid points

If you don't like the system then don't use it :)

I'll get the admins to have a look at it.
0
ellandrdAuthor Commented:
>>it won't even compiled (as u yourself stated)
>>And the corrected version was copied from my previous comments.

look at: Date: 03/23/2006 11:03AM GMT - this is the code i used and you got credit for your comments

>>which should have been a seperate question.
>>the solution to your problem required no change to your build script
>>as I \stated you just needed to include the xsl in your classpath

OK, fair point - but i didnt know how to do this, hence why i asked for help with it.

you could have said stop, this question is not related to changing build.xml so open new Q. but you didnt - you continued to provide comments to help me change my build.xml:

Date: 03/23/2006 10:50AM GMT
Date: 03/23/2006 11:36AM GMT
Date: 03/23/2006 11:55AM GMT

Yes - i'll take the blame for not seeing this (opening new thread), but i should have been corrected.

>>Yes, but I don't expect the points for it after someone else has alr3eaqdy answered the question.

Its called been fair - if i awarded CEHJ all the points you'd be giving out, saying you helped me - next thing i'd see is comment from mods and question reopened...

so to bypass this, i split the points.

>>I'll get the admins to have a look at it.

do what you want - i dont care - as far as i can see, the mods have looked at this question and have made there comments on it to you: http://www.experts-exchange.com/Community_Support/Q_21788228.html

you are never happy with any decisions i make anyway so whats the point?

there is times when i open questions and you comment, and i think yes - objects just commented - he'll help me out... but then i think oh no - he's sooooo picky and will be on my back for a few days as the decisions/comments i make, he wont like...

this site is meant to be trying to hold onto members - not push them away and this is exactly what you doing!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.