simple compilation problem - extends

J

James

This must be something very simple, but . . . Why does this code
not compile?

import java.io.File;
import java.util.*;
import java.util.zip.*;

public class OpenXMLpackage extends ZipFile
{

}

The NetBeans IDE gives the error:

init:
deps-jar:
Created dir: C:\...\My Java Code\OpenXML\OpenXML\build\classes
Compiling 1 source file to C:\...\My Java Code\OpenXML\OpenXML\build
\classes
C:\...\My Java Code\OpenXML\OpenXML\src\OpenXMLpackage.java:14: cannot
find symbol
symbol : constructor ZipFile()
location: class java.util.zip.ZipFile
public class OpenXMLpackage extends ZipFile
1 error
BUILD FAILED (total time: 1 second)

I am simply trying to extend the ZipFile class. Thanks,
Alan
 
A

Arne Vajhøj

James said:
This must be something very simple, but . . . Why does this code
not compile?

import java.io.File;
import java.util.*;
import java.util.zip.*;

public class OpenXMLpackage extends ZipFile
{

}
C:\...\My Java Code\OpenXML\OpenXML\src\OpenXMLpackage.java:14: cannot
find symbol
symbol : constructor ZipFile()
location: class java.util.zip.ZipFile
public class OpenXMLpackage extends ZipFile
1 error
BUILD FAILED (total time: 1 second)

Sounds as if you have a default constructor that tries to
call a non existing default constructor of ZipFile.

Just make an explicit constructor call.

Arne
 
I

Ian Shef

Sounds as if you have a default constructor that tries to
call a non existing default constructor of ZipFile.

NOTE: The compiler will attempt to insert a call to the no-argument
constructor of ZipFile unless you call some other constructor yourself (see
below). ZipFile does not have a no-argument constructor and you did not
call any other constructor of ZipFile.
Just make an explicit constructor call.
This will look like super(...) where the ... must be replaced by parameters
appropriate for one of the ZipFile constructors, e.g.
super("my_file_name.txt") ;

Note also that this must be the executable statement of the constructors
for OpenXMLpackage.
<snip>

Going out on a limb...

James, are you certain that you need to extend ZipFile ? Perhaps
OpenXMLpackage has_a ZipFile, instead of OpenXMLpackage is_a ZipFile ?
 
J

James

Thank you.

Also, a real-world OpenXML file (Office 2007) actually is a
ZipFile. It is a zipped file containing XML files.

Alan
 
J

James

OK, I understand now. . . I needed a default constructor because the
superclass I am extending (ZipFile) only has non-default
constructors. This means that its subclass does not include an
implicit call to super(). So, I have to explicitly call a superclass
constructor, as below.

Thanks, Alan

public class OpenXMLpackage extends ZipFile
{
OpenXMLpackage(String filename) throws Exception
{
super(filename);
}
}
 
A

Arne Vajhøj

James said:
Also, a real-world OpenXML file (Office 2007) actually is a
ZipFile. It is a zipped file containing XML files.

Are you aware of the complexity of OOXML ?

It is not a simple task to implement !

I would use some kind of SDK for it.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top