Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Error Reading File

Posted on 2006-03-23
109
Medium Priority
?
374 Views
Last Modified: 2012-06-27
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!



0
Comment
Question by:ellandrd
  • 46
  • 38
  • 24
108 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 1000 total points
ID: 16267676
>>File file = new File( "etc/rss.xsl" ) ;

is wrong for where your program is being run from. Run from newsreader
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16267681
so my path is wrong yes?
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 1000 total points
ID: 16267686
Other options:

a. use an absolute path
b. use a URL and getResource(), specifying correctly in relation to your classpath/packages
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 16

Author Comment

by:ellandrd
ID: 16267687
cool ok...
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16267699
see using Absolute path, where would i start it from? newsreader or my c:\?
0
 
LVL 92

Expert Comment

by:objects
ID: 16267704
how are you running it?
0
 
LVL 92

Expert Comment

by:objects
ID: 16267710
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
 
LVL 16

Author Comment

by:ellandrd
ID: 16267714
Standalone application - im planning of distributing it by webstart...
0
 
LVL 92

Assisted Solution

by:objects
objects earned 1000 total points
ID: 16267723
> 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
 
LVL 16

Author Comment

by:ellandrd
ID: 16267726
>>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
 
LVL 92

Assisted Solution

by:objects
objects earned 1000 total points
ID: 16267727
> 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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16267735
If using Webstart, option b. in my comment is best
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16267743
>>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
 
LVL 16

Author Comment

by:ellandrd
ID: 16267747
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16267750
>>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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16267753
>>what to see it?

I assume you mean *want* to see it. Not yet ;-)
0
 
LVL 92

Assisted Solution

by:objects
objects earned 1000 total points
ID: 16267760
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
 
LVL 16

Author Comment

by:ellandrd
ID: 16267761
i get "jar" not recognised
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16267770
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
 
LVL 92

Expert Comment

by:objects
ID: 16267771
the build is using a base diretcory of:

C:\newsreader\build\classes\

it should be:

C:\newsreader
0
 
LVL 92

Expert Comment

by:objects
ID: 16267776
> 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
 
LVL 92

Expert Comment

by:objects
ID: 16267780
the code you have currently won't work with the xsl in the jar, you need to change it
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16267782
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
 
LVL 92

Expert Comment

by:objects
ID: 16267791
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
 
LVL 92

Expert Comment

by:objects
ID: 16267796
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
 
LVL 16

Author Comment

by:ellandrd
ID: 16267809
ok but im not too sure how i add te xsl file or this etc folder into the jar file?
0
 
LVL 92

Expert Comment

by:objects
ID: 16267836
add the directory to the file list in your jar build target
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16267840
Please post the output of

jar tf yourjar.jar
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16267855
>>Date: 03/23/2006 10:56AM GMT
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16267863
Oh, OK. You need to add %JAVA_HOME%\bin to your path
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16267871
(Creating the variable JAVA_HOME [the installation directory of your JDK] first if necessary)
0
 
LVL 92

Expert Comment

by:objects
ID: 16267882
theres no need to run jar :)
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16267918
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16267959
>>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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16267968
xslSource = getResource("etc/rss.xsl" )  ;

Since it's already added, the above should work
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16267974
Sorry

xslSource = getResource("/etc/rss.xsl" )  ;
0
 
LVL 92

Expert Comment

by:objects
ID: 16267975
following covers the jar target

http://ant.apache.org/manual/CoreTasks/jar.html
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16267987
method getResource not found?

0
 
LVL 92

Expert Comment

by:objects
ID: 16268000
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16268004
Sorry - not quite awake

getClass().getResource(................................
0
 
LVL 92

Expert Comment

by:objects
ID: 16268014
> method getResource not found?

see what I suggested earlier.

using the above build it would be:

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

Author Comment

by:ellandrd
ID: 16268021
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16268039
>>like this

No - you need to compile it before you jar it
0
 
LVL 92

Expert Comment

by:objects
ID: 16268041
see my comment above:

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

and move the builkding of jar, *after* the jjavac
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16268062
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
 
LVL 92

Expert Comment

by:objects
ID: 16268067
sorry, should have been:

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

Author Comment

by:ellandrd
ID: 16268076
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
 
LVL 16

Author Comment

by:ellandrd
ID: 16268083
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
 
LVL 92

Expert Comment

by:objects
ID: 16268091
forgot to change the run target :)
it needs to include the jar in the classpath instead of the classes onm disk

0
 
LVL 92

Expert Comment

by:objects
ID: 16268102
> 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
 
LVL 92

Expert Comment

by:objects
ID: 16268118
       <java classname="${project.main.class}" fork="true" classpath="${basedir}/rssreader.jar" dir="${basedir}">
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16268126
>><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
 
LVL 16

Author Comment

by:ellandrd
ID: 16268128
>>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
 
LVL 92

Expert Comment

by:objects
ID: 16268156
see my comment above
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16268159
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
 
LVL 16

Author Comment

by:ellandrd
ID: 16268192
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
 
LVL 16

Author Comment

by:ellandrd
ID: 16268247
i hate when people dont reply ;-)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16268260
List the jar

jar tf rssreader.jar

, using the full path to jar.exe if necessary
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16268302
the output is:

META-INF
u0207372
rss.xsl
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16268310
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16268328
There's no application in there! - Just two directories and your xsl file
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16268350
what do you mean?

what is mean to be in there?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16268359
All your classes. Can you post the output of

dir build/classes /s/b
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16268363
Sorry - that was meant to be

All your classes. Can you post the output of

dir build\classes /s/b
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16268411
it contains all my .class files
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16268512
Please post output
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16268513
you still there? when you go offline tell me...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16268529
Yes
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16268564
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16268566
Going off for few minutes
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16268579
*You* must do what i ask then - so far you haven't ;-) Back soon
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16268757
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16269208
Is there a package specified in NRStandalone.java?
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16269224
package u0207372 ;
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16269270
is there a way we could copy all the etc folder into the jar file instead of just the rss.xsl?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16269286
OK. Can you please copy and paste (i include the prompt below) the output of

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

?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16269310
>> 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
 
LVL 16

Author Comment

by:ellandrd
ID: 16269320
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16269389
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16269421
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
 
LVL 16

Author Comment

by:ellandrd
ID: 16269429
>>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
 
LVL 16

Author Comment

by:ellandrd
ID: 16269450
>>Also, replace the java task with the following:
>><java jar="rssreader.jar" fork="true" dir="${basedir}" />

eh? lost
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16269462
As in http:Q_21785541.html#16267974

See my last correction too
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16269474
>>eh? lost

Use that instead of

  <java classname="${project.main.class}" fork="true" classpath="${basedir}/rssreader.jar" dir="${basedir}/build/classes" />
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16269480
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16269520
>>as i dont know where it goes...

It goes where i said - in place of where the previous java task was
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16269524
run:
java.lang.NoClassDefFoundError: u0207372/NRStandalone
Exception in thread "main"
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16269561
jar tf rssreader.jar

output please
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16269600
newsreader
META-INF
build
dist
doc
etc
nbproject
src
test
NewsReader.jnlp
applet.policy
build.xml
manifest.mf
readme.html
run.bat
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16269643
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
 
LVL 16

Author Comment

by:ellandrd
ID: 16269670
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16269736
OK - looks like the output file has now changed, can you post the output of

jar tf dist\newsreader.jar
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16269756


it working!!!!! yes - can eat now - havnt eaten since 6.30 dismorning...
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16269768
kinda need to pull myself from outta this chair now...
cheers for the help..

just wanna do one more test before accepting....
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16269985
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16269995
With any luck you should be able to start that by double-clicking the jar
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16270063
>>jar="NewsReaderApp.jar"

But that isn't the jar is it?
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16270071
its ok i fixed it...
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16270092
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16270160
I would normally do

<fileset dir="${basedir}/build/classes" includes="**/*.*"/>
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16270509
:-)
0
 
LVL 92

Expert Comment

by:objects
ID: 16274726
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
 
LVL 92

Expert Comment

by:objects
ID: 16276664
and his earlier comment that you accepted is wrong:

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



0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16278276
It isn't wrong ;-)
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16278369
>>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
 
LVL 16

Author Comment

by:ellandrd
ID: 16278375
p.s im not here to argue with people over some stupid points
0
 
LVL 92

Expert Comment

by:objects
ID: 16285789
> 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
 
LVL 16

Author Comment

by:ellandrd
ID: 16287522
>>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

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month15 days, 7 hours left to enroll

575 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question