Visual J++ Reference

The Visual J++ Reference contains the following topics:

  • Visual J++ Code Model

  • Extensibility in Visual J++

  • Conditional Compilation

  • Reserved Words, A-L

  • Reserved Words, M-Z


Visual J++ Code Model

The COM interfaces that make up the Visual J++ Code Model provide access to information about the code in your current project. Much of this information is obtained by a background parser that runs under the Visual J++ development environment. This parser continually processes the code, rebuilding parse trees and symbol tables in response to every change. The Code Model interfaces expose the contents of these trees and tables in a format that provides easy programmatic access from any automation-capable language. The interfaces also permit callers to modify the code.

The Visual J++ Code Model is used by various parts of Visual J++, including the source code editor, the class browser, and various wizards and designers. It can also be used by third-party add-ins.

For detailed information, see the following interfaces:

  • IJavaBlockStatement

  • IJavaClass

  • IJavaClasses

  • IJavaCodeSense

  • IJavaCommentTags

  • IjavaCompileUnit

  • IJavaCompileUnitEvents

  • IJavaDocComment

  • IJavaField

  • IJavaImports

  • IJavaInitializer

  • IJavaInitializers

  • IJavaMember

  • IJavaMembers

  • IJavaMethod

  • IJavaPackage

  • IJavaPackages

  • IJavaSourceElement

  • IJavaSourceElements

  • IJavaStatement

See the following for information on:

  • JavaClassModifier, JavaClassModifiers

  • JavaMemberModifier, JavaMemberModifiers

  • JavaNameSearchFlag, JavaNameSearchFlags

  • JavaNamespaceFlag, JavaNamespaceFlags

  • JavaPrototypeFlag, JavaPrototypeFlags

  • JavaReferenceType

  • JavaStatementType


IJavaBlockStatement Interface

The IJavaBlockStatement interface represents a Java block statement (a statement enclosed in braces and containing zero or more statements). It functions as a collection of statements.

IJavaBlockStatement : IJavaStatement

This interface defines the following members.

Member | Description
AddStatementText | Inserts a new statement at the given index.
Count | Returns the number of statements contained in this block.
Item | Returns the IJavaStatement at the given index.
RemoveStatementAt | Removes a statement from the block.


IJavaBlockStatement::AddStatementText

Inserts a new statement at the given index.

Syntax

HRESULT AddStatementText([in] BSTR bstrStatementText, [in] long nIndex);

Sub AddStatementText(ByVal bstrStatementText As String, ByVal nIndex As Long)

This syntax has these parts:

Parameters

bstrStatementText

String. Statement text.

nIndex

The index of the existing member before which the new statement should be inserted. To insert the new statement at the end of the class, pass –1 as the index.


IJavaBlockStatement::Count

This property returns the number of statements contained in this block.

Syntax

[propget] HRESULT Count([out, retval] long* retval);

Property Count As Long


IJavaBlockStatement::Item

This function returns the IJavaStatement at the given index.

Syntax

HRESULT Item([in] VARIANT index, [out, retval] IJavaStatement** ppMember);

Function Item(ByVal index) As IJavaStatement

Parameters

index

Variant reference to IJavaStatement.


IJavaBlockStatement::RemoveStatementAt

Removes a statement from the block as specified by its index.

Syntax

HRESULT RemoveStatementAt([in] long nIndex);

Sub RemoveStatementAt(ByVal nIndex As Long)

Parameters

nIndex

The index of the existing block statement to be removed.


IJavaClass Interface

The IJavaClass interface represents a Java class, interface, or delegate.

IJavaClass : IJavaSourceElement

This interface defines the following members.

Member | Description
AddField | Adds a field class member.
AddMethod | Adds a method class member.
CanOverride | Indicates whether the class can override the given method.
FullName | Represents the fully qualified name of the class.
GetBlockRange | Returns the range of text containing the class.
GetBodyRange | Returns the text range containing the class's body.
GetNameRange | Returns the starting position and length of the range of text containing the class's name.
Initializers | A collection of the initializers declared within the class.
InnerClasses | A collection of the inner classes declared within the class.
Interfaces | A collection of the interfaces that the class implements.
IsClass | Indicates whether the IJavaClass object represents a class.
IsDelegate | Indicates whether the IJavaClass object represents a delegate.
IsInterface | Indicates whether the IJavaClass object represents an interface.
IsSubclassOf | Traverses the superclass chain and compares the superclasses' names with the given string.
Members | A collection of the members of the class, both fields and methods.
Modifiers | Provides access to the class's modifiers.
Name | Represents the simple name of the class.
OverrideMethod | Inserts a method declaration and code stub for the given method.
Package | A reference to the package that contains the class.
RemoveMember | Removes a class member.
Superclass | Provides access to the IJavaClass object representing the class's superclass.
Subclasses | A collection of all classes that inherit from this class.
SuperclassName | Provides access to the name of the class's superclass.


IJavaClass::AddField

Use this method to add a field class member.

Syntax

HRESULT AddField(
[in] JavaMemberModifiers mods,
[in] BSTR pType,
[in] BSTR bstrName,
[in] BSTR bstrInitializer,
[in] long nIndex,
[out, retval] IJavaField** retval
);

Function AddField(ByVal mods As Long, ByVal pType As String, ByVal bstrName As String, ByVal bstrInitializer As String, ByVal nIndex As Long) As IJavaField

Parameters

mods

Modifiers for the new field.

pType

The type signature for the type of the new field.

bstrName

The name of the new field.

bstrInitializer

The initial value expression for the new field. Can be Null.

nIndex

The index of the existing member before which the new field should be inserted. To insert the new field at the end of the class, pass –1 as the index.


IJavaClass::AddMethod

Use this method to add a method class member.

Syntax

HRESULT AddMethod([in] JavaMemberModifiers mods, [in] BSTR bstrSignature,
[in] BSTR bstrName, [in] BSTR bstrFormalNames,
[in] BSTR bstrBodyText, [in] long nIndex,
[out, retval] IJavaMethod** retval);

Function AddMethod(ByVal mods As Long, ByVal bstrSignature As String, ByVal bstrName As String, ByVal bstrFormalNames As String, ByVal bstrBodyText As String, ByVal nIndex As Long) As IJavaMethod

Parameters

mods

Modifiers for the new method.

bstrSignature

The type signature for the new method, including parameter types and the return type.

bstrName

The name of the new method.

bstrFormalNames

A comma-separated list of the formal parameter names for the new method.

bstrBodyText

The text to be inserted as the body of the new method. May be Null.

nIndex

The index of the existing member before which the new method should be inserted. To insert the new method at the end of the class, pass –1 as the index.

Remarks

To add a constructor to a class, call AddMethod with no return type specified in the signature and a name that is identical to the class name.


IJavaClass::CanOverride

Indicates whether the class can override the given method. This is determined by searching the class's methods for a prototype matching the given method. If one is found, or if the given method cannot be overridden for other reasons (for example, it is a final method), VARIANT_FALSE is returned, indicating that a call to OverrideMethod would result in uncompilable code.

Syntax

HRESULT CanOverride(

[in] IJavaMethod* pMethod,
[out, retval] VARIANT_BOOL* retval
);

Property CanOverride(pMethod As IJavaMethod) As Boolean

Parameters

pMethod

Reference to the method to be overridden.


IJavaClass::FullName

The FullName property represents the fully qualified name of the class, including its package name.

Syntax

HRESULT FullName([out, retval] BSTR* retval);

Property Get FullName As String


IJavaClass::GetBlockRange

This method returns the range of text containing the class, including all white space preceding the class declaration. These values are expressed in character units relative to the compile unit's text buffer.

Syntax

HRESULT GetBlockRange(
[out] long* pnStart,
[out] long* pnLength
);

Sub GetBlockRange(pnStart As Long, pnLength As Long)

Parameters

pnStart

Long. Starting position, in character units relative to the compile unit's text buffer.

pnLength

Long. Length, in character units relative to the compile unit's text buffer.


IJavaClass::GetBodyRange

This method returns the text range containing the class's body. The range begins with a left bracket ({) and ends with a right bracket (}). These values are expressed in character units relative to the compile unit's text buffer.

Syntax

HRESULT GetBodyRange(
[out] long* pnStart,
[out] long* pnLength
);

Sub GetBodyRange(pnStart As Long, pnLength As Long)

Parameters

pnStart

Long. Starting position, in character units relative to the compile unit's text buffer.

pnLength

Long. Length, in character units relative to the compile unit's text buffer.


IJavaClass::GetNameRange

This method returns the starting position and length of the range of text containing the class's name. These values are expressed in character units relative to the compile unit's text buffer.

Syntax

HRESULT GetNameRange([out] long* pnStart, [out] long* pnLength);

Sub GetNameRange(pnStart As Long, pnLength As Long)

Parameters

pnStart

Long. Starting position, in character units relative to the compile unit's text buffer.

pnLength

Long. Length, in character units relative to the compile unit's text buffer.


IJavaClass::Initializers

This property is a collection of the initializers declared within the class.

Syntax

HRESULT Initializers([out, retval] IJavaInitializers** retval);

Property Get Initializers As IJavaInitializers


IJavaClass::InnerClasses

This property is a collection of the inner classes declared within the class. This collection includes both nested top-level classes and member classes. It does not include local or anonymous classes.

Syntax

HRESULT InnerClasses([out, retval] IJavaClasses** retval);

Property Get InnerClasses As IJavaClasses


IJavaClass::Interfaces

This property is a collection of the interfaces that the class implements.

Syntax

HRESULT Interfaces([out, retval] IJavaClasses** retval);

Property Get Interfaces As IJavaClasses


IJavaClass::IsClass

This property indicates whether the IJavaClass object represents a class.

Syntax

HRESULT IsClass([out, retval] VARIANT_BOOL* retval);

Property Get IsClass As Boolean


IJavaClass::IsDelegate

This property indicates whether the IJavaClass object represents a delegate.

Syntax

HRESULT IsDelegate([out, retval] VARIANT_BOOL* retval);

Property Get IsDelegate As Boolean


IJavaClass::IsInterface

This property indicates whether the IJavaClass object represents an interface.

Syntax

HRESULT IsInterface([out, retval] VARIANT_BOOL* retval);

Property Get IsInterface As Boolean


IJavaClass::IsSubclassOf

Traverses the superclass chain and compares the superclasses' names with the given string. If a match is found, returns VARIANT_TRUE. The given string can be a fully qualified dotted name or not.

Syntax

[propget] HRESULT IsSubclassOf([in] BSTR bstrName, [out, retval] VARIANT_BOOL* retval);

Property IsSubclassOf(ByVal bstrName As String) As Boolean

Parameters

bstrName

The class name to check.


IJavaClass::Members

This property is a collection of the members of the class, both fields and methods. The collection can be filtered in various ways with the optional parameters passed when getting the property.

Syntax

HRESULT Members(
[in, defaultvalue("")] BSTR bstrName,
[in, defaultvalue(0)] VARIANT_BOOL fIncludeInherited,
[in, defaultvalue(0)] IJavaClass *pWhoIsAsking,
[in, defaultvalue(0)] JavaNamespaceFlags flags,
[out,retval] IJavaMembers **ppMembers
);

Property Members([ByVal bstrName As String], [ByVal fIncludeInherited As Boolean], [pWhoIsAsking As IJavaClass], [ByVal flags As Long]) As IJavaMembers

Parameters

bstrName

Member name to return.

fIncludeInherited

Passing VARIANT_TRUE adds members from all superclasses to the collection.

pWhoIsAsking

Reference to IJavaClass member.

flags

JavaNamespaceFlags flag.

Remarks

The bstrName parameter allows you to retrieve members with a particular name. Passing VARIANT_TRUE for the fIncludeInherited parameter adds members from all superclasses to the collection. Passing an IJavaClass pointer in the pWhoIsAsking parameter excludes members from the collection that are not accessible from the given class. Finally, flags from the JavaNamespaceFlags enumeration can be specified.


IJavaClass::Modifiers

This property provides access to the class's modifiers.

Syntax

[propget] HRESULT Modifiers([out, retval] JavaMemberModifiers* retval);

[propput] HRESULT Modifiers([in] JavaMemberModifiers newval);

Property Modifiers As Long

Parameters

newval

New class modifier value.

Remarks

The modifiers are flag bits drawn from the JavaClassModifier enumeration.


IJavaClass::Name

These properties provide access to the name of the class. The Name property represents the simple name of the class. For example, in the class java.awt.Graphics, the Name property is "Graphics" and the FullName property is "java.awt.Graphics."

Syntax

[propget] HRESULT Name([out, retval] BSTR* retval);

[propput] HRESULT Name([in] BSTR newval);

Property Name As String

Parameters

newval

New class name value.


IJavaClass::OverrideMethod

Inserts a method declaration and code stub for the given method.

Syntax

HRESULT OverrideMethod([in] IJavaMethod* pMethod);

Sub OverrideMethod(pMethod As IJavaMethod)

Parameters

pMethod

The method to be overridden.


IJavaClass::Package

This property is a reference to the package that contains the class.

Syntax

HRESULT Package([out, retval] IJavaPackage** retval);

Property Get Package As IJavaPackage


IJavaClass::RemoveMember

Use this method to remove a class member.

Syntax

HRESULT RemoveMember([in] IJavaMember* pMember);

Sub RemoveMember(pMember As IJavaMember)

Parameters

pMember

The member to remove.


IJavaClass::Subclasses

This property is a collection of all classes that inherit from this class. All classes in installed packages (including those along the CLASSPATH) and in open Visual J++ projects are searched.

Syntax

[propget] HRESULT Subclasses([out, retval] IJavaClasses** retval);

Property Subclasses As IJavaClasses


IJavaClass::Superclass

This property provides access to the IJavaClass object representing the class's superclass.

Syntax

[propget] HRESULT Superclass([out, retval] IJavaClass** retval);

[propput] HRESULT Superclass([in] IJavaClass* newval);

Property Superclass As IJavaClass

Parameters

newval

New superclass name value.


IJavaClass::SuperclassName

This property provides access to the name of the class's superclass.

Syntax

[propget] HRESULT SuperclassName([out, retval] BSTR* retval);

[propput] HRESULT SuperclassName([in] BSTR newval);

Property SuperclassName As String


IJavaClasses Interface

This interface is used to enumerate classes in a compile unit or package, as well as interfaces, inner classes, and subclasses of a class.

IJavaClasses : IDispatch

This interface defines the following members.

Member | Description
Add | Inserts a class or interface into the collection by modifying the code that the collection describes.
Count | The number of classes in the collection.
Item | Returns an IJavaClass item from the collection.
Remove | Removes a class from the collection by modifying the code that the collection describes.


IJavaClasses::Add

Inserts a class or interface into the collection by modifying the code that the collection describes. The method's parameters allow specification of the name of the new class, whether the class or interface keyword should be used, and the position at which to insert the class into the collection.

Syntax

HRESULT Add([in] BSTR bstrName, [in] VARIANT_BOOL bClass, [in] long nIndex, [out, retval] IJavaClass** retval);

Function Add(ByVal bstrName As String, ByVal bClass As Boolean, ByVal nIndex As Long) As IJavaClass

Parameters

bstrName

The name of the new class.

bClass

Indicates whether a new class or interface is to be inserted.

nIndex

The index of the existing class before which the new class is to be inserted. To insert the new class at the end of the collection, pass –1 as the index.


IJavaClasses::Count

Returns the number of classes in the collection.

Syntax

[propget] HRESULT Count([out, retval] long* pCount);

Property get Count As Long


IJavaClasses::Item

Returns an IJavaClass item from the collection. The VARIANT index provided specifies either the name of a class to search for or an integer index.

Syntax

HRESULT Item(
[in] VARIANT index,
[out, retval] IJavaClass** ppClass
);

Function Item(ByVal index) As IJavaClass

Parameters

index

Variant. Class item index or name of a class.


IJavaClasses::Remove

Removes a class from the collection by modifying the code that the collection describes.

Syntax

HRESULT Remove(
[in] IJavaClass* pClass);

Sub Remove(pClass As IJavaClass)

Parameters

pClass

Reference to the class in the collection that is to be removed.


IJavaCodeSense Interface

The IJavaCodeSense interface is the primary interface for the Visual J++ Code Model service, providing global Code Model operations. It is accessed by calling IServiceProvider::QueryService, with SID_SJavaCodeSense as the service ID:

hr = QueryService (SID_SJavaCodeSense, IID_IJavaCodeSense, &pICS)

This interface defines the following members.

Member | Description
Class | Returns a class object for the named class, searching relative to the given base directory.
CompileUnit | Provides access to a compile unit.
Package | Returns a package object for the named package, searching relative to the given base directory.
SourceElements | Provides access to a collection of one or more named Java source code elements.


IJavaCodeSense::Class

Returns a class object for the named class, searching relative to the given base directory.

Syntax

HRESULT Class(
IJavaClass* BSTR bstrName,
[in] BSTR bstrCurrentDirectory,
[in] DWORD dwFlags
);

Property Class(ByVal bstrClassName As String, ByVal bstrCurrentDirectory As String, ByVal dwFlags As Unsigned Long) As IJavaClass

Parameters

bstrClassName

Required string. Class name specification.

bstrCurrentDirectory

String. Current directory file specification.

dwFlags

JavaNamespaceFlags flag.

Remarks

Classes are identified by their names within the Java namespace (such as java.lang.String). An optional directory name parameter specifies a starting point for locating the requested class. This directory is substituted for the period wherever it appears in the CLASSPATH.


IJavaCodeSense::CompileUnit

This property provides access to a compile unit (a file containing one or more classes).

Syntax

HRESULT CompileUnit(
[in]BSTR bstrFileName,
IJavaCompileUnit* retval
);

Property Get CompileUnit(FileName As String) As IJavaCompileUnit

Parameters

FileName

Required string. A full path that identifies the file containing one or more classes.

Remarks

Compile units are identified by fully qualified file names (for example, C:\MyClasses\Foo.java). The file name extension is optional. If a file with the .java extension does not exist, but a corresponding .class file does exist, the Visual J++ Code Model uses the .class file to obtain as much information as possible about the class.

Return Value

The following value is obtained from the returned HRESULT.

Return value | Meaning
S_OK | Success


IJavaCodeSense::Package

Returns a package object for the named package, searching relative to the given base directory.

Syntax

HRESULT Package(
[in] BSTR bstrName
[in] VARIANT_BOOL fPublic
[in] BSTR bstrDir
[out, retval]IJavaPackage** retval
);

Property Get CompileUnit(FileName As String) As IJavaCompileUnit

Parameters

FileName

Required string. A full path that identifies the file containing one or more classes.

fPublic

Boolean. Determines if this property is public.

bstrDir

String. Base directory.

Remarks

Packages are identified by their names within the Java namespace (such as java.lang). An optional directory name parameter specifies a starting point for locating the requested package. This directory is substituted for a period wherever it appears in the CLASSPATH.


IJavaCodeSense::SourceElements

This property provides access to a collection of one or more named Java source code elements (classes, methods, or fields).

Syntax

HRESULT SourceElements(
[in] BSTR bstrName
[in] JavaNameSearchFlags flags
[out, retval]IJavaSourceElements **retval
);

Property SourceElements(ByVal bstrName As String, ByVal flags As Long) As IjavaSourceElements

Parameters

bstrName

Required string. Class, method, or field.

flags

Long. Reserved for internal use only.

Remarks

If more than one element matches the specified name (for example, overloaded methods and classes in different packages), all such source elements are included in the returned collection.


IJavaCommentTags Interface

This is a generic interface to the four types of tag collections in a documentation comment (Links, Authors, Params, and Exceptions). It provides standard enumeration methods as well as Add/Remove methods for manipulating the content.

IJavaCommentTags : IDispatch

This interface defines the following members.

Member | Description
Add | Adds a new tag to the collection.
Count | Provides the number of tags in the collection.
Item | Looks up a tag by name or index.
Remove | Removes a tag from the collection.


IJavaCommentTags::Add

Adds a new tag to the collection. The tag name is the same as the others in the collection.

Syntax

HRESULT Add(
[in] BSTR bstrText,
[in] long nIndex
);

Sub Add(ByVal bstrText As String, ByVal nIndex As Long)

Parameters

bstrText

String. Tag text.

nIndex

The index of the existing member before which the new comment tag should be inserted. To insert the new comment tag at the end of the class, pass –1 as the index.


IJavaCommentTags::Count

This property provides the number of tags in the collection.

Syntax

[propget] HRESULT Count([out, retval] long* retval);

Property Count as Long


IJavaCommentTags::Item

The VARIANT index provided specifies either an integer index in the collection or a name which searches the first word following the tag.

Syntax

HRESULT Item(
[in] VARIANT varIndex,
[out, retval] BSTR* retval

);

Function Item(ByVal varIndex) As String

Parameters

varIndex

Specifies either an integer index in the collection or a name.

Remarks

The named lookup is useful in the Params and Exceptions collections because the first word contains the name of the parameter or type of exception, which is subsequently documented.


IJavaCommentTags::Remove

Removes a tag from the collection. Either a string or an integer can be passed in the VARIANT parameter.

Syntax

HRESULT Remove([in] VARIANT varIndex);

Sub Remove(ByVal varIndex)

Parameters

varIndex

String or integer identifying the tag in the collection to be removed.


IJavaCompileUnit Interface

This interface represents a Java compile unit (source file).

public interface IJavaCompileUnit extends Iunknown

The interface contains the following properties and methods.

Method | Description
Classes | Collection of the classes in the compile unit.
ClassFromType | Returns a class for a given type signature.
FindPackage | Returns the package with a specified name.
Imports | Collection of the compile unit's imported package and class names.
Package | Provides access to the package containing this compile unit.
PackageName | Name of the package containing this compile unit.
PrimaryClassName | The name of the primary (public) class in this compile unit.
ProjectItem | The VJProjectItem that corresponds to the compile unit.
ReadOnly | Indicates whether the compile unit can be modified.
SaveChanges | Commits changes that have been made in the compile unit, unless the user has the file open for editing.
TextFromType | Converts a type signature to a type name in text format.
TypeFromText | Converts a type name in text format to a type signature.


IJavaCompileUnit::Classes

Provides access to the classes that are contained in the compile units of the package.

Syntax

HRESULT Classes(
[out, retval] IJavaClasses** retval
);

Property Classes As IJavaClasses


IJavaCompileUnit::ClassFromType

This property returns the class corresponding to the given type signature.

Syntax

HRESULT ClassFromType([in] BSTR bstrType, [out, retval] IJavaClass** retval);

Function ClassFromType(ByVal bstrType As String) As IJavaClass

Parameters

bstrType

The type signature.

Remarks

If the type signature represents a primitive type or an array type, the property access fails.


IJavaCompileUnit::FindPackage

This method returns the package that contains a class with the given name. The name resolution is performed relative to the namespace of the compile unit.

Syntax

HRESULT FindPackage([in] BSTR bstrName,
[out, retval] IJavaPackage** retval);

Function FindPackage(ByVal bstrName As String) As IJavaPackage

Parameters

bstrName

The name of the requested package.


IJavaCompileUnit::Imports

This property is a collection of the names of packages and classes that are imported by the compile unit. For a compiled .class file, this collection is always empty.

Syntax

HRESULT Imports(
[out, retval] IJavaImports** retval
);

Property Imports As IJavaImports


IJavaCompileUnit::Package

Provides access to the name of the IJavaPackage object representing the package for the compile unit.

Syntax

HRESULT Package([out, retval] IJavaPackage** retval);

Property Get Package As IJavaPackage


IJavaCompileUnit::PackageName

Provides access to the name of the compile unit's package.

Syntax

HRESULT PackageName([out, retval] BSTR* retval);

Property Get PackageName As String


IJavaCompileUnit::PrimaryClassName

This property is the name of the primary class in the compile unit.

Syntax

HRESULT PrimaryClassName([out, retval] BSTR* retval);

Property Get PrimaryClassName As String

Remarks

This is the name of the class that matches the compile unit's file name (typically, this is the public class in the compile unit).


IJavaCompileUnit::ProjectItem

This read-only property returns the VJProjectItem that corresponds to the IJavaCompileUnit, if there is one. This property returns Null if the IJavaCompileUnit does not represent a file of Java code that is part of the current solution.

Property ProjectItem As VJExt._VJProjectItem


IJavaCompileUnit::ReadOnly

This property indicates whether the compile unit can be modified.

Syntax

HRESULT ReadOnly(
VARIANT_BOOL* retval
);

Property ReadOnly As Boolean

Remarks

A compile unit can be read-only if source code is not available.


IJavaCompileUnit::SaveChanges

This method causes any changes to the compile unit's text buffer to be saved to disk.

Syntax

HRESULT SaveChanges();

Sub SaveChanges

Remarks

If the buffer is successfully saved, the method returns S_OK. If the buffer is currently locked for editing (for example, open in an editor window), the buffer is not saved, and the method returns S_FALSE. If the buffer cannot be saved for any other reason, the method fails.


IJavaCompileUnit::TextFromType

This property returns the textual (Java source code) representation of a type that corresponds to a type signature. The given type signature must conform to the Java signature format. A parameter specifies whether a class name appearing in the returned name should be expressed as a simple name or as a fully qualified name.

Syntax

HRESULT TextFromType(
[in] JavaReferenceType jrt,
[in] IJavaCompileUnit* pUnitDest,
[in] BSTR bstrType,
[out, retval] BSTR* retval
);

Function TextFromType(ByVal jrt As JavaReferenceType, pUnitDest As IJavaCompileUnit, bstrType As String) As String

Parameters

jrt

Flag from the JavaReferenceType enumeration specifying the type of reference name requested.

pUnitDest

The compile unit in which the type name is used. Can be Null.

bstrType

The type signature to be converted.


IJavaCompileUnit::TypeFromText

This property returns the type signature that corresponds to the textual (Java source code) representation of a type.

Syntax

HRESULT TypeFromText(
[in] BSTR bstrText,
[out, retval] BSTR* retval
);

Function TypeFromText(ByVal bstrText As String) As String

Parameters

bstrText

The type name to be converted.

Remarks

The given textual type can represent a primitive type (such as char, short), a class type (for example, String), or an array type (such as int[]). The given textual type is interpreted relative to the namespace of the compile unit, which includes all imported classes and all other classes in the compile unit's package. The returned type signature conforms to the Java signature format, as defined in Section 2.2, Lexical Grammar, in the Java Virtual Machine Specification.


IJavaCompileUnitEvents Interface

This is an outgoing (event) interface provided by the compile unit through the standard connection point mechanism. If you implement this interface, you can query the compile unit object for IID_IConnectionPointContainer and then call its FindConnectionPoint method with IID_IJavaCompileUnitEvents as the parameter. On the connection point interface returned, you can pass your event handler to the Advise method.

Note You can also register to receive this event from the CodeSense object. In this case, your handler will receive events from all compile units.

This interface defines the following members.

Member | Description
OnCompileUnitChanged | Signals that the objects created by the parser may have changed.


IJavaCompileUnitEvents::OnCompileUnitChanged

This event is fired immediately after the CodeSense parser runs. It signals that the objects created by the parser may have changed.

Syntax

HRESULT OnCompileUnitChanged(
[in]IJavaCompileUnit* pUnit);
};

Sub OnCompileUnitChanged(pUnit As IJavaCompileUnit)

Parameters

pUnit

The compile unit that has changed.

Remarks

The parser runs only when information is requested from a CodeSense object, and the buffer has been changed since the last parse.


IJavaDocComment Interface

The IJavaDocComment interface represents the documentation comment for a class, field, or method.

IJavaDocComment : Idispatch

A documentation comment is delimited by /** and */ and immediately precedes the source element that it describes. For a description of the contents of documentation comments, see Chapter 18 of The Java Language Specification.

This interface defines the following members.

Member | Description
Authors | Provides access to the first of @author tags in the documentation comment.
Description | Provides access to all text preceding the first tag in the comment.
Exception | Provides access to the list of @exception tags in the documentation comment.
Links | Provides access to the list of @see tags in the documentation comment.
Params | Provides access to the list of @param tags in the documentation comment.
RemoveTag | Deletes a tag with the given name.
Return | Provides access to the @return tag in the documentation comment.
Summary | Provides access to the summary sentence of the documentation comment.
TagValue | Allows read/write access to the tag with the given name.
Text | Provides access to the complete text of the documentation comment.
Version | Provides access to the @version tag in the documentation comment.


IJavaDocComment::Authors

This property provides access to the list of @author tags in the documentation comment.

Syntax

[propget] HRESULT Authors([out, retval] IJavaCommentTags** retval);

Property Authors As IJavaCommentTags


IJavaDocComment::Description

This property provides access to all text preceding the first tag in the comment, including the summary sentence.

Syntax

[propget] HRESULT Description([out, retval] BSTR* retval);

[propput] HRESULT Description([in] BSTR newval);

Property Description As String


IJavaDocComment::Exceptions

This property provides access to the list of @exception tags in the documentation comment.

Syntax

[propget] HRESULT Exceptions([out, retval] IJavaCommentTags** retval);

Property Exceptions As IJavaCommentTags


IJavaDocComment::Links

This property provides access to the list of @see tags in the documentation comment.

Syntax

[propget] HRESULT Links([out, retval] IJavaCommentTags** retval);

Property Links as IJavaCommentTags


IJavaDocComment::Params

This property provides access to the list of @param tags in the documentation comment.

Syntax

[propget] HRESULT Params([out, retval] IJavaCommentTags** retval);


IJavaDocComment::RemoveTag

This method deletes a tag with the given name.

Syntax

HRESULT RemoveTag([in] BSTR bstrTagName);

Sub RemoveTag(ByVal bstrTagName As String)

Parameters

bstrTagName

The name of the tag to be removed.


IJavaDocComment::Return

This property provides access to the @return tag in the documentation comment.

Syntax

[propget] HRESULT Return([out, retval] BSTR* retval);

[propput] HRESULT Return([in] BSTR newval);

Property Return As String

Parameters

newVal

The new return tag string value.


IJavaDocComment::Summary

This property provides access to the summary sentence of the documentation comment.

Syntax

[propget] HRESULT Summary([out, retval] BSTR* retval);

Property Get Summary As String


IJavaDocComment::TagValue

This property allows read/write access to the tag with the given name.

Syntax

[propget] HRESULT TagValue([in] BSTR bstrTagName, [out, retval] BSTR* retval);

[propput] HRESULT TagValue([in] BSTR bstrTagName, [in] BSTR newval);

Property TagValue(ByVal As String) As String

Parameters

bstrTagName

The return tag string value.

newVal

The new tag string value.


IJavaDocComment::Text

This property provides access to the complete text of the documentation comment. Leading spaces and asterisks are stripped from the beginning of each line.

Syntax

[propget] HRESULT Text([out, retval] BSTR* retval);

[propput] HRESULT Text([in] BSTR newval);

Property Text As String

Parameters

newVal

The new text string value.


IJavaDocComment::Version

This property provides access to the @version tag in the documentation comment.

Syntax

[propget] HRESULT Version([out, retval] BSTR* retval);

[propput] HRESULT Version([in] BSTR newval);

Property Version As String

Parameters

newVal

The new version string value.


IJavaField Interface

The IJavaField interface represents a field of a class. IJavaField is derived from IJavaMember.

interface IJavaField : IJavaMember

This interface defines the following members.

Member | Description
InitialValue | Provides access to the field's initial value expression.


IJavaField::InitialValue

This property provides access to the field's initial value expression, if any. If the field has no initial value, the InitialValue property is Null.

Syntax

[propget] HRESULT InitialValue([out, retval] BSTR* retval);

[propput] HRESULT InitialValue([in] BSTR newval);

Property InitialValue As String


IJavaImports Interface

The IJavaImports interface allows enumeration of the import statements in a compile unit.

IJavaImports : IDispatch

This interface defines the following members.

Member | Description
Add | Adds an import statement for the given package to the compile unit.
Count | Returns the number of import statements in the compile unit.
Item | Returns the name of the imported package or class at the given index.
Remove | Removes the given import statement from the compile unit.


IJavaImports::Add

This function adds an import statement for the given package to the compile unit.

Syntax

HRESULT Add([in] BSTR bstrName);

Sub Add(ByVal bstrName As String)

Parameters

bstrName

The import statement string value to be added.


IJavaImports::Count

This property returns the number of import statements in the compile unit.

Syntax

[propget] HRESULT Count([out, retval] long* pCount);

Property Count As Long


IJavaImports::Item

This function returns the name of the imported package or class at the given index.

Syntax

HRESULT Item([in] VARIANT index, [out, retval] BSTR* retval);

Function Item(ByVal index) As String

Parameters

index

The reference within the package or class.


IJavaImports::Remove

Removes the given import statement from the compile unit.

Syntax

HRESULT Remove([in] BSTR bstrName);

Sub Remove(ByVal bstrName As String)


IJavaInitializer Interface

The IJavaInitializer interface represents a static or instance initializer.

IJavaInitializer : IJavaSourceElement

This interface defines the following members.

Member | Description
Body | Allows enumeration of the statements that make up the initializer.
Modifiers | Provides access to the initializer's modifiers.


IJavaInitializer::Body

This property allows enumeration of the statements that make up the initializer.

Syntax

[propget] HRESULT Body([out, retval] IJavaBlockStatement** retval);

Property Body As IJavaBlockstatement


IJavaInitializer::Modifiers

This property provides access to the initializer's modifiers. The only relevant bit flag for an initializer is JMM_STATIC.

Syntax

[propget] HRESULT Modifiers([out, retval] JavaMemberModifiers* retval);

Property Modifiers As Long


IJavaInitializers Interface

The IJavaInitializers interface allows enumeration of the class initializers.

IJavaInitializers : IDispatch

This interface defines the following members.

Member | Description
Count | Returns the number of initializers in the class.
Item | Returns the IJavaInitializer at the given index.


IJavaInitializers::Count

This property returns the number of initializers in the class.

Syntax

[propget] HRESULT Count([out, retval] long* pCount);

Property Count As Long


IJavaInitializers::Item

This function returns the IJavaInitializer at the given index.

Syntax

HRESULT Item([in] VARIANT index, [out, retval] IJavaInitializer** retval);

Function Item(ByVal index) As IJavaInitializer


IJavaMember Interface

The IJavaMember interface represents a member (field or method) of a class.

IJavaMember : IJavaSourceElement

This interface defines the following members.

Member | Description
Class | Provides access to the class containing the member.
GetBlockRange | Returns the range of text containing the member.
GetNameRange | Returns the starting position and length of the range of text containing the member's name.
IsField | Indicates that the member is a field.
IsMethod | Indicates that the member is a method.
Modifiers | Provides access to the member's modifiers.
Name | Provides access to the member's name.
Type | Provides access to the member's type.


IJavaMember::Class

This property provides access to the class containing the member.

Syntax

[propget] HRESULT Class([out, retval] IJavaClass** retval);

Property Class As IJavaClass


IJavaMember::GetBlockRange

This method returns the range of text containing the member, including all white space preceding the member declaration. These values are expressed in character units relative to the compile unit's text buffer.

Syntax

HRESULT GetBlockRange([out] long* pnStart, [out] long* pnLength);

Sub GetBlockRange(pnStart As Long, pnLength As Long)

Parameters

pnStart

Long. Starting position, in character units relative to the compile unit's text buffer.

pnLength

Long. Length, in character units relative to the compile unit's text buffer.


IJavaMember::GetNameRange

This method returns the starting position and length of the range of text containing the member's name. These values are expressed in character units relative to the compile unit's text buffer.

Syntax

HRESULT GetNameRange([out] long* pnStart, [out] long* pnLength);

Sub GetNameRange(pnStart As Long, pnLength As Long)

Parameters

pnStart

Long. Starting position, in character units relative to the compile unit's text buffer.

pnLength

Long. Length, in character units relative to the compile unit's text buffer.


IJavaMember::IsField

This property indicates that the member is a field.

Syntax

[propget] HRESULT IsField([out, retval] VARIANT_BOOL* retval);

Property IsField As Boolean


IJavaMember::IsMethod

This property indicates that the member is a method.

Syntax

[propget] HRESULT IsMethod([out, retval] VARIANT_BOOL* retval);

Property IsMethod As Boolean


IJavaMember::Modifiers

This property provides access to the member's modifiers.

Syntax

[propget] HRESULT Modifiers([out, retval] JavaMemberModifiers* retval);

[propput] HRESULT Modifiers([in] JavaMemberModifiers newval);

Property Modifiers As Long

The modifiers flags are specified in the JavaMemberModifier enumeration.


IJavaMember::Name

This property provides access to the member's name.

Syntax

[propget] HRESULT Name([out, retval] BSTR* retval);

[propput] HRESULT Name([in] BSTR newval);

Property Name As String


IJavaMember::Type

This property provides access to the member's type. For a method, the Type property indicates the method's return type. The type is returned as a type signature string. If the member is a constructor method, the type signature is an empty string.

Syntax

[propget] HRESULT Type([out, retval] BSTR* retval);

[propput] HRESULT Type([in] BSTR newval);

Property Type As String


IJavaMembers Interface

This interface is used to enumerate class members.

IJavaMembers : IDispatch

This interface defines the following members.

Member | Description
Count | The number of members in the collection.
Item | The VARIANT index provided specifies an integer index in the collection.
UniqueField | Returns the field of the specified name.


IJavaMembers::Count

The number of members in the collection.

Syntax

[propget] HRESULT Count([out, retval] long* pCount);

Property Count As Long


IJavaMembers::Item

The VARIANT index provided specifies an integer index in the collection.

Syntax

HRESULT Item([in] VARIANT index, [out, retval] IJavaMember** ppMember)

Function Item(ByVal index) As IJavaMember

Parameters

index

Variant. Integer index of the item in the collection.


IJavaMembers::UniqueField

If the collection represents all overloaded class members with the same name (differing only by their parameters), it contains at most one field element because there can only be one field with any given name. This method returns that field, if any.

Syntax

[propget] HRESULT UniqueField ([out,retval] IJavaField **ppField);

Property UniqueField As IJavaField


IJavaMethod Interface

The IJavaMethod interface represents a method of a class.

interface IJavaMethod : IJavaMember

This interface defines the following members.

Member | Description
AddFormal | Adds a new formal parameter to the method.
Body | Provides access to the block statement that makes up the body of the method.
Exceptions | A collection of the exceptions this method can throw.
FormalCount | Provides access to the count of the method's formal parameters.
FormalNameAt | Provides access to the name of one of the method's formal parameters.
FormalNames | Provides access to the method's list of formal parameter names.
FormalTypeAt | Provides access to the type of one of the method's formal parameters.
FormalTypes | Provides access to the method's list of formal parameter types.
GetBodyRange | Returns the range of text containing the method's block statement.
IsConstructor | Indicates whether the method is a constructor.
RemoveFormal | Removes a formal parameter from the method.
RemoveFormalAt | Removes a formal parameter from the method using the index.


IJavaMethod::AddFormal

Adds a new formal parameter to the method.

Syntax

HRESULT AddFormal([in] BSTR pType, [in] BSTR bstrName, [in] long nIndex);

Sub AddFormal(ByVal pType As String, ByVal bstrName As String, ByVal nIndex As Long)

Parameters

pType

The type signature for the new formal parameter.

bstrName

The name of the new formal parameter.

nIndex

The index of the existing formal parameter after which to insert the new one. To insert a new parameter at the end of the list, pass –1 as the index.


IJavaMethod::Body

This property provides access to the block statement that makes up the body of the method.

Syntax

[propget] HRESULT Body([out, retval] IJavaBlockStatement** retval);

Property Body As IJavaBlockStatement


IJavaMethod::Exceptions

This property is a collection of the exceptions this method can throw.

Syntax

[propget] HRESULT Exceptions([out, retval] IJavaClasses** retval);

Property Exceptions As IJavaClasses


IJavaMethod::FormalCount

Provides access to the count of the method's formal parameters.

Syntax

HRESULT FormalCount([out, retval] long* retval);

Property Get FormalCount As Long


IJavaMethod::FormalNameAt

Provides access to the name of one of the method's formal parameters.

Syntax

[propget] HRESULT FormalNameAt([in] long nIndex, [out, retval] BSTR* retval);

[propput] HRESULT FormalNameAt([in] long nIndex, [in] BSTR newval);

Property FormalNameAt(ByVal nIndex As Long) As String

Parameters

nIndex

Long. Reference to the location of the formal parameter.


IJavaMethod::FormalNames

Provides access to the method's list of formal parameter names. The formal names are returned as a comma-separated list.

Syntax

HRESULT FormalNames([out, retval] BSTR* retval);

Property Get FormalNames As String


IJavaMethod::FormalTypeAt

Provides access to the type of one of the method's formal parameters. The formal type is returned in type signature format.

Syntax

[propget] HRESULT FormalTypeAt([in] long nIndex, [out, retval] BSTR* retval);

[propput] HRESULT FormalTypeAt([in] long nIndex, [in] BSTR newval);

Property FormalTypeAt(ByVal nIndex As Long) As String

Parameters

nIndex

Long. Reference to the location of the formal parameter.


IJavaMethod::FormalTypes

Provides access to the method's list of formal parameter types. The formal types are returned in type signature format.

Syntax

HRESULT FormalTypes([out, retval] BSTR* retval);

Property Get FormalTypes As String


IJavaMethod::GetBodyRange

This method returns the range of text containing the method's block statement, beginning with a left bracket ({) and ending with a right bracket (}). These values are expressed in character units relative to the compile unit's text buffer.

Syntax

HRESULT GetBodyRange([out] long* pnStart, [out] long* pnLength);

Sub GetBodyRange(pnStart As Long, pnLength As Long)

Parameters

pnStart

Long. Position in the text buffer to begin.

pnLength

Long. Block statement length in characters.


IJavaMethod::IsConstructor

This property indicates whether the method is a constructor.

Syntax

Property get IsConstructor As Boolean.


IJavaMethod::RemoveFormal

Removes a formal parameter from the method.

Syntax

HRESULT RemoveFormal([in] BSTR bstrName);

Sub RemoveFormal(ByVal bstrName As String)

Parameters

bstrName

The name of the formal parameter to remove.


IJavaMethod::RemoveFormalAt

Removes a formal parameter from the method.

Syntax

HRESULT RemoveFormalAt([in] long nIndex);

Sub RemoveFormalAt(ByVal nIndex As Long)

Parameters

nIndex

The index of the formal parameter to remove.


IJavaPackage Interface

The IJavaPackage interface represents a Java package. A package is a directory in the file system or an installed archive, such as a .cab or .zip file. A package is a collection of compile units and a collection of subpackages. A package also has a name and can have a parent package.

This interface defines the following members.

Member | Description
Classes | A collection of the classes in the package.
Name | Provides access to the name of the package in the Java namespace.
ParentPackage | Provides access to the parent package of the package.
SubPackages | A collection of the subpackages in the package.


IJavaPackage::Classes

This property is a collection of the classes in the package.

HRESULT Classes(
[out, retval] IJavaClasses** retval
);

Property Classes As IJavaClasses


IJavaPackage::Name

This property provides access to the name of the package in the Java namespace, for example, java.lang.

Syntax

HRESULT Name(
[out, retval] BSTR* retval);

Property Name As String


IJavaPackage::ParentPackage

This property provides access to the parent package of the package.

Syntax

HRESULT ParentPackage(
[out, retval] IJavaPackage** retval
);

Property ParentPackage As IJavaPackage

The parent package is contained in the parent directory of the package directory. The parent package is Null if the current package is a top-level package.


IJavaPackage::SubPackages

This property is a collection of the subpackages in the package.

Syntax

SubPackages(
[out, retval] IJavaPackages** retval
);

Property SubPackages As IJavaPackages


IJavaPackages Interface

This interface represents a collection of package collections.

This interface defines the following members.

Member | Description
Count | Returns the number of packages in the collection.
Item | Returns one package in the collection of packages.
PackageNamed | Returns the named package in the collection of packages.


IJavaPackages::Count

This property returns the number of packages in the collection.

Syntax

HRESULT Count([out, retval] long* retval);

Property Get Count As Long


IJavaPackages::Item

This method returns one package in the collection of packages. The VARIANT index provides lookup by name or by integer index.

Syntax

HRESULT Item(
[in] VARIANT index,
[out, retval] IJavaPackage** retval
);

Function Item(ByVal index) As IJavaPackage

Parameters

index

Variant. Reference to the package by name or by integer index.


IJavaPackages::PackageNamed

This property returns the named package in the collection of packages.

Syntax

HRESULT PackageNamed(
[in] BSTR bstrName,
[out, retval] IJavaPackage **retval
);

Property get PackageNamed(ByVal bstrName As String) As IJavaPackage

Parameters

bstrName

String. Package name.


IJavaSourceElement Interface

The IJavaSourceElement interface is a common interface shared by the interfaces that represent various elements appearing within a compile unit. These interfaces include IJavaClass, IJavaMember, and IJavaStatement.

IJavaSourceElement : Idispatch

This interface defines the following members.

Member | Description
CompileUnit | Refers to the compile unit that contains the source element.
DocComment | Provides access to the member's documentation comment.
GetRange | Returns the starting position and length of the range of text containing the source element.
IsValid | Indicates whether the source element object is valid.
Prototype | Returns a prototype string for the source element.


IJavaSourceElement::CompileUnit

This property refers to the compile unit that contains the source element.

Syntax

[propget] HRESULT CompileUnit([out, retval] IJavaCompileUnit** retval);

Property CompileUnit As IJavaCompileUnit


IJavaSourceElement::DocComment

This property provides access to the member's documentation comment, if any.

Syntax

HRESULT DocComment([out, retval] IJavaDocComment** retval);

Property Get DocComment As IJavaDocComment


IJavaSourceElement::GetRange

This method returns the starting position and length of the range of text containing the source element. These values are expressed in character units relative to the compile unit's text buffer.

Syntax

HRESULT GetRange(
[out] long* pnStart,
[out] long* pnLength
);

Sub GetRange(pnStart As Long, pnLength As Long)

Parameters

pnStart

Long. Starting position, in character units relative to the compile unit's text buffer.

pnLength

Long. Length, in character units relative to the compile unit's text buffer.


IJavaSourceElement::IsValid

This property indicates whether the source element object is valid.

Syntax

[propget] HRESULT IsValid([out, retval] VARIANT_BOOL* retval);

Property Get IsValid As Boolean

Remarks

A source element object may be invalid if the compile unit has been changed since the source element was first accessed.


IJavaSourceElement::Prototype

This property returns a prototype string for the source element.

Syntax

HRESULT Prototype([in] JavaPrototypeFlags jpf, [out, retval] BSTR* retval);

Property Get Prototype(ByVal jpf As Long) As String

Parameters

jpf

Formatting flags in JavaPrototypeFlag for the prototype string

Remarks

The property takes a JavaPrototypeFlags parameter that describes which components of the prototype to include.


IJavaSourceElements Interface

The IJavaSourceElements interface allows enumeration of source elements. This collection is returned by the SourceElements property of the IJavaCodeSense interface.

interface IJavaSourceElements : Idispatch

This interface defines the following members.

Member | Description
Count | Returns the number of source elements in the collection.
Item | Returns the source element at the given index.


IJavaSourceElements::Count

This property returns the number of source elements in the collection.

Syntax

[propget] HRESULT Count([out, retval] long* pCount);

Property Count As Long


IJavaSourceElements::Item

This function returns the source element at the given index.

Syntax

HRESULT Item([in] VARIANT index, [out, retval] IJavaSourceElement** retval);

Function Item(ByVal index) As IJavaSourceElement

Parameters

index

Variant. Reference into the SourceElements collection for the specified source element.


IJavaStatement Interface

The IJavaStatement interface represents a statement within a Java method or initializer.

IJavaStatement : IJavaSourceElement

This interface defines the following members.

Member | Description
StatementType | Indicates the type of statement.
Text | Provides access to the text of the statement.


IJavaStatement::StatementType

This property indicates the type of statement.

Syntax

[propget] HRESULT StatementType([out, retval] JavaStatementType* retval);

Property StatementType As JavaStatementType

The statement type is a value from the JavaStatementType set:


IJavaStatement::Text

This property provides access to the text of the statement.

Syntax

HRESULT Text([out, retval] BSTR* retval);

Property Text As String


JavaClassModifier, JavaClassModifiers

The following flags are associated with this enumeration.

JCM_PUBLIC

JCM_PRIVATE

JCM_PROTECTED

JCM_FINAL

JCM_ABSTRACT


JavaMemberModifier, JavaMemberModifiers

The following flags are associated with this enumeration.

Flag | Equals
JMM_PUBLIC | 0x0001
JMM_PRIVATE | 0x0002
JMM_PROTECTED | 0x0004
JMM_STATIC | 0x0008
JMM_FINAL | 0x0010 (valid only for methods)
JMM_SYNCHRONIZED | 0x0020
JMM_VOLATILE | 0x0040 (valid only for fields)
JMM_TRANSIENT | 0x0080 (valid only for fields)
JMM_NATIVE | 0x0100 (valid only for methods)
JMM_ABSTRACT | 0x0400 (valid only for methods)


JavaNamespaceFlag, JavaNamespaceFlags

The following flags are associated with this enumeration:

JNF_TYPESONLY | Internal use only
JNF_STATICONLY | Only static class members
JNF_INVOLVED | Internal use only
JNF_IMPORT | Names that can appear in import statements
JNF_PACKAGE | Internal use only
JNF_INCLUDEPROTECTED | Internal use only
JNF_CONSTRUCTORSONLY | Constructors only


JavaNameSearchFlag, JavaNameSearchFlags

The following flags are associated with this enumeration:

JNSF_NOOPENPROJECTS | No open projects
JNSF_NOINSTALLEDPACKAGES | No installed packages
JNSF_NOCLASSES | No classes
JNSF_NOMEMBERS | No members


JavaPrototypeFlag, JavaPrototypeFlags

The following flags are associated with this enumeration:

JPF_NONAME | Do not include the element's name in the prototype. It is mutually exclusive with JPF_CLASSNAME and JPF_FULLNAME
JPF_CLASSNAME | If the element is a member of a class, prepend the name of the class and a period to the name.
JPF_FULLNAME | Prepend the package name to the class name. Includes JPF_CLASSNAME.
JPF_TYPE | For class members, include the type of the field or return type of the method before its name.
JPF_PARAMTYPES | For methods, include a list of parameter types in parentheses after the name.
JPF_PARAMNAMES | Include the parameter names.
JPF_FULLTYPENAMES | Specifies fully qualified names for reference types included in the prototype.


JavaReferenceType

The following flags are associated with this enumeration:

Flag | Equals
JRT_NOCHANGE | Leave the class name exactly the way it appears in the source code.
JRT_SHORT | Return the simple class name with no package name.
JRT_FULL | Return the full class name, including package name, if any.
JRT_MINIMAL | Return the shortest possible class name; if the class is imported by the compile unit, or is part of the same package as the compile unit, return the simple class name; otherwise, return the full class name.


JavaStatementType Enumeration

JavaStatementType

The following flags are associated with this enumeration:

Flag | Equals
JST_EMPTY | 0,
JST_BLOCK | 1,
JST_IF | 2,
JST_WHILE | 3,
JST_DO | 4,
JST_FOR | 5,
JST_SWITCH | 6,
JST_CASE | 7,
JST_TRY | 8,
JST_BREAK | 9,
JST_CONTINUE | 10,
JST_LABEL | 11,
JST_RETURN | 12,
JST_THROW | 13,
JST_SYNC | 14,
JST_EXPRESSION | 15,
JST_DECLARATION | 16,
JST_SWITCHLABEL | 17,
JST_LOCALCLASS | 18,


Extensibility in Visual J++

Additions to the Visual Studio extensibility object model specific to Visual J++ are described in this section.

  • VJProject Object, VJProjects Collection

  • VJProjectItem Object, VJProjectItems Collection

  • VJProperty Object, VJProperties Collection

  • Events Object

  • VJProjectEvents Object, VJProjectItemsEvents Object

  • SelectedItem Object, SelectedItems Collection


VJProject Object, VJProjects Collection

The VJProjects collection contains all Visual J++ projects in the solution. You can access just the collection of Visual J++ projects with DTE.VJProjects.

Remarks

The Visual J++ package defines a VJProjects collection that is immediately accessible from the DTE object. This collection contains a project object for each Visual J++ project in the solution.


VJProjectItem Object, VJProjectItems Collection

The VJProjectItem object represents an item contained in a Visual J++ project.

The VJProjectItems collection contains all VJProjectItem objects in the current instance of the development environment.


Code Property

Returns the root object of the model for Java code in a file.

Syntax

Property Get Code() As IJavaCompileUnit


VJProperty Object, VJProperties Collection

The VJProperty object represents a property of another object. It provides a way to associate a property with an object other than accessing it from the object as in object1.property1.

The VJProperties collection contains all currently available VJProperty objects.


Events Object (Visual J++)

Allows access to all events in the extensibility model. Events are also exposed from specific objects within the extensibility model.

Remarks

The extensibility model contains a root Events object from which add-ins can reference objects supporting general, core extensibility events; for example, DTE.Events.SolutionEvents and the AddProject event. From the root Events object add-ins can also reference objects supporting product-specific events, such as DTE.Events.VJProjectItemsEvents and the ItemAdded event. The environment resolves the name VJDesignerEvents in the registry to dynamically find a type library describing the object that supports events.


VJProjectsEvents Property

Returns the VJProjectEvents object.

Syntax

Property Get VJProjectsEvents([filter As Object]) As VJProjectsEvents

Parameters

filter

If not Null, this is a VJProject object indicating that the resulting VJProjectsEvents object will source events only for the specified VJProject object.


VJProjectItemsEvents Property

Returns the VJProjectItemsEvents object.

Syntax

Property Get VJProjectItemEvents([filter As Object]) As VJProjectItemsEvents

Parameters

filter

If not Null, this is a VJProjectItem indicating that the resulting VJProjectItemsEvents object will source events only for the specified VJProject object.


VJProjectsEvents Object

VJProjectsEvents Object, VJProjectItemsEvents Object

These event objects handle the following events:

  • ItemAdded Event

  • ItemRemoved Event

  • ItemRenamed Event


ItemAdded Event (Visual J++)

This event is triggered just after adding a VJProject object.

Syntax

Sub ItemAdded (object As VJProject)

Sub ItemAdded (object As VJProjectItem)

Parameters

object

The item just added.


ItemRemoved Event (Visual J++)

This event is triggered just after removing a VJProject or VJProjectItem.

Syntax

ProjectEvents object:

Sub ItemRemoved (object As VJProject)

ProjectItemsEvents object:

Sub ItemRemoved (object As VJProjectItem)

Parameters

object

The item just removed.


ItemRenamed Event (Visual J++)

This event is triggered just after renaming a VJProject or VJProjectItem.

Syntax

ProjectItemsEvents object:

Event ItemRenamed (object As VJProjectItem, oldname As String)

ProjectEvents object:

Event ItemRenamed (object As VJProject, oldname As String)

Parameters

object

The item just renamed.

oldname

The previous name of the item.


SelectedItem Object, SelectedItems Collection

The SelectedItem object represents a selected project or project item.

The SelectedItems collection returns a collection of all SelectedItem objects.

Remarks

Use the SelectedItem object to get the project with the focus to provide context for an add-in.

A project always has a SelectedItems collection, even when there are no project items selected. For example, if the Project Explorer has focus and a project node is selected, there is one SelectedItem object. That selected item's Project property points to the selected project, and the ProjectItem property is Null.

When a file that is not a project item is selected in the alternate directory view, the SelectedItem.Info field provides the full path to the selected file. The Project and ProjectItem properties are set to Null.

For Visual J++, the following fields are also used:

  • .Name Display name for the item (for example, the name displayed in the Project Explorer)

  • .Info(i) Indexed property of additional information about the selected item. This is used when the alternate directory view is shown in the Project Explorer, and a file is selected that is not in the project. .Info(1) contains the full path to the file.

  • .InfoCount The number of strings in .Info. This is always 1 for Visual J++.


Conditional Compilation

Visual J++ provides two new mechanisms for conditionally compiling code in Java: conditional directives and conditional methods. The table below describes all the conditional directives available. For an overview, see Conditional Directives. For an overview describing the syntax and use of conditional methods, see Conditional Methods.

Note The conditional directive and conditional method mechanisms provided with Visual J++ are extensions to the Java language, provided by Microsoft. Thus, source code containing these mechanisms will not compile properly with other Java development tools.

Conditional Directive | Description
#if | Conditionally includes or excludes source code, depending on the resulting value of its expression or identifier.
#elif | Optional use with the #if directive. If the previous #if test fails, #elif includes or excludes source code, depending on the resulting value of its own expression or identifier.
#else | Optional use with the #if directive. If the previous #if test fails, source code following the #else directive will be included.
#endif | Required use with the #if directive. The #endif directive closes a conditional block of code.
#define | Defines an identifier used in preprocessing.
#undef | Undefines an identifier used in preprocessing.
#error | Generates a developer-defined error message at compile-time.
#warning | Generates a developer-defined warning message at compile-time.


The #if, #elif, #else, and #endif Conditional Directives

The #if, #elif, #else, and #endif directives are used together to allow lines of source code to be conditionally included or excluded from the compilation of a source file. The #if directive, which begins all conditional blocks, must be matched by a closing #endif directive.

Syntax

#if <expression1>

code to be included

#elif <expression2>

code to be included

#else

code to be included

#endif

The expression following the #if and #elif directives must be a valid boolean expression, comprised of boolean operators and using identifiers declared with the #define or #undef compiler directives. If the expression following the #if directive evaluates to true, lines immediately following the directive are retained in the source file. If, however, the expression has the value false, the lines immediately following the directive are excluded from the source file until the #elif, #else, or #endif directive is encountered.

Only one #else directive can be included in a conditional block. Lines following the #else directive are retained in the source file only if the associated expression evaluated by the #if directive evaluates to false.

Zero or more #elif directives can be included within a conditional block of code. The #elif directive, an abbreviation of "else if," is used for subsequent evaluation of expressions, where the #if directive has already been evaluated and proven to be false.

Expressions used in conditional compilation have some of the same limitations and behaviors as those imposed by the Java language. For example, all the Java defined boolean and bitwise operators are accepted, and operator precedence is identical. Furthermore, the Java language also defines the use of parenthesis to force the order of evaluation.

The following example illustrates using each of these conditional directives:

#define DEBUG
#undef RETAIL

public class test {

    #if DEBUG
        if (cmdStatus.equals(invokeError))
        {
            // The following line displays a diagnostic message:
            System.out.println("Error: command timed out.");
            // appropriate actions
            // taken here
        }
    #elif RETAIL
        if (cmdStatus.equals(invokeError))
        {
            // appropriate actions
            // taken here
        }
    #else
        #error Must define DEBUG or RETAIL;
    #endif
}


The #define Conditional Directive

The #define directive is used to include a conditional identifier into a source file. When defined, the identifier can be used in all the classes contained within the source file. The directive must be placed at the top of the source file, with only comments and other conditional compilation directives preceding it.

By convention, the value of the identifier declared by the #define directive will always be true.

Syntax

#define <identifier>

The identifier shown above can be up to 1024 characters in length. By convention, identifiers are composed of uppercase characters to clarify their usage.

The following example illustrates use of the #define directive in a Java application:

    #define DEBUG  // DEBUG evaluates as true.

    #if DEBUG
        // code to be included
    #endif

Note The Visual J++ build process does not allow per-file build settings. This means that in order to turn on and off conditional identifiers within a single source file, the #define and #undef directives must be explicitly declared within each file.


The #undef Conditional Directive

The #undef directive, as its name implies, is used to remove an identifier from a source file. The identifier need not be defined beforehand, and can be redefined again within the source file using the #define directive. The #undef directive must be placed at the top of the source file, with only comments and other conditional directives preceding it.

Syntax

#undef <identifier>

The identifier shown above can be up to 1024 characters in length. By convention, identifiers are usually composed of uppercase characters to clarify their usage.

The following example illustrates use of the #undef directive in a Java application:

    #undef DEBUG  // DEBUG evaluates to false

    #if DEBUG    // now set to false.
        // lines extracted at compile-time
    #endif

Note The Visual J++ build process does not allow per-file build settings. This means that in order to turn on and off conditional identifiers within a single source file, the #define and #undef directives must be explicitly declared within each file.


The #error Conditional Directive

The #error directive takes a string as an argument and produces an error message at compile-time. Errors produced by this directive are displayed as normal compiler errors.

Like the #warning directive, this directive is most useful for detecting pre-defined constraints and inconsistencies during preprocessing of the source file.

Syntax

#error <message string>

The message string identifier shown above indicates the error message to be displayed. The following example illustrates use of the #error directive:

    #if DEBUG
        ...
    #elif RETAIL
        ...
    #else
       #error DEBUG or RETAIL must be defined!
    #endif

When the error above is encountered, the following line will be output:

    #error 'DEBUG or RETAIL must be defined' (J0500)


The #warning Conditional Directive

The #warning directive takes a string as an argument and produces a warning message at compile-time. Warnings produced by this directive are displayed as normal compiler warnings.

Like the #error directive, this directive is most useful for detecting pre-defined constraints and inconsistencies during preprocessing of a source file.

Syntax

#warning <message string>

The message string identifier shown above indicates the warning message to be displayed. The following example illustrates use of the #warning directive:

    #if !TRACING
        #warning This interface has not been completely tested yet!
    #endif

When the warning above is encountered, the following line will be output:

    #warning 'This interface has not been completely tested yet!' (J5500)


Conditional Methods

Conditional methods use the @conditional tag embedded within Java documentation comments to conditionally include or exclude entire methods from a source file. When a conditional method is excluded from a source file, the compiler automatically eliminates calls to the method from elsewhere within the program.

Syntax

/** @conditional (expression) */

void someMethod(args)

{

…

}

The expression shown above can be any valid Java expression, using identifiers declared with the #define or #undef compiler directives.

The greatest benefit conditional methods provide is a simple way to include or exclude large amounts of debug information from an application. For example, a number of conditional methods may be created to generate vital diagnostic information during the development process. Once development is complete and the application is ready for release, all conditional methods, the expressions used to include them, and any calls can be easily eliminated from the compiled application by merely changing the value of an identifier.

The following example illustrates use of a conditional method:

#define DEBUG   //DEBUG is true
 ...
    public class someClass {
    . . .
        /** @conditional (DEBUG) */
        trackDisplay(int dTrack)
        {
            System.out.println("Variable dTrack assigned: %d", dTrack);
        }
}

In the code above, defining the DEBUG identifier allows the trackDisplay conditional method to be compiled. Once the method is no longer useful to the developer, replacing the #define directive with the #undef directive will cause the compiler to extract the method from compilation of the source file, and nullify any calls made to the method from elsewhere within the program.


Conditional Directives

Conditional directives are used to include or exclude blocks of code from a source file, based on the result of an expression, or the value of a single identifier. Conditional directives are useful in many aspects of development, among them:

  • They can be used to selectively include or exclude vital diagnostic, or debug code. Once an application containing conditional directive-based code is ready for release, the code can be easily eliminated from the project.

  • They can be used to experiment with several possible code optimizations. For example, if various implementations of an algorithm need to be examined for efficiency, setting the appropriate conditional identifier can instantly switch the code execution path to a different algorithm.

The following example demonstrates the use of conditional directives:

# define PRINTHELLO    // PRINTHELLO has the value 'true'

public class sample {

    public static void main(String args[])
    {
        #if PRINTHELLO
            System.out.println("Hello!");
        #else
           System.out.println("Goodbye.");
        #endif
    }
}

In the example shown above, the string "Hello!" will be displayed. Removing the #define directive will display the string "Goodbye."

Like standard conditional constructs in Java, several of the conditional compilation directives also make use of expressions that govern their flow. For example, the #if compiler directive, like it’s Java language equivalent — the if statement, makes use of Java identifiers and operators to form expressions. Thus, most of the rules that govern the syntax of creating syntactically correct statements in the Java language also apply to the creation of expressions for conditional directives. One notable exception where the language syntax rules do not apply is in the use of multi-line comment blocks.

Conditional directives must be alone on a line, except for single-line comments. Multi-line comments may not begin or end on the same line as a conditional directive.

Used wisely, conditional directives can save you considerable time and effort in debugging code.


Reserved Words (A-L)

abstract | delegate | if
boolean | do | implements
break | double | import
byte | else | instanceof
case | extends | int
catch | false | interface
char | final | long
class | finally | multicast
continue | float |
default | for |


abstract

The abstract keyword can be used in the declaration of classes and methods. Use of the keyword in a class declaration typically means that one or more of the methods within the class body are declared as abstract. If the keyword is left off the class declaration, and a method within the body of the class is declared using the abstract keyword, then the class is implicitly defined to be abstract. In other words, the keyword abstract need not be provided as part of the class declaration in this circumstance, and the code will compile successfully. (For readability it is recommended that abstract class declarations include the keyword to make the class intention clear.)

Classes declared to be abstract cannot be instantiated. Instead, abstract classes force the programmer to provide a body for each abstract method within a new derived class. The following example shows a simple abstract class and a class derived from it:

public abstract class FruitClass
{

    public boolean isPeelable( );

    .
    .
    .
}

public class BananaClass extends FruitClass
{

    private boolean bPeel;

    public boolean isPeelable( ) {
        .
        .
        .
        return bPeel;
    }

}

The derived class (BananaClass) may be instantiated, and any non-abstract methods of the abstract class (FruitClass) will be inherited unless they are overridden.

Note that a class declaration cannot use abstract and final.

The abstract keyword can also be used to define methods. As already shown above, a class containing abstract methods is then also (either implicitly or explicitly) defined as abstract and must be subclassed in order to be instantiated. An abstract method cannot have the implementation defined within the abstract class. Rather, it is declared with arguments and a return type as usual, but the body that is enclosed in curly braces is replaced with a semicolon.

Consider the following example declaration of an abstract method:

abstract public int someMethod( int arg1, int arg2);

Note that a method declared with the keyword abstract cannot be declared with the keywords static, private, or final.


boolean

The boolean keyword is used to declare a primitive Java data type containing a truth value. The two possible values of a boolean variable are true and false. Note that true and false are defined as keywords in the Java language, but they are actually literal values. Hence, the keywords true and false can be used as return values, in conditional tests, and in assignments and comparisons to other boolean variables.

The contents of boolean variables cannot be cast to or from other types; the current value of a boolean variable can be converted to a string however.

The following code demonstrates declaration and assignment for a boolean variable:

private boolean isRunning;

isRunning = true;


break

The break keyword is used to define a break statement which, without a label, transfers control out of the innermost enclosing while, do, for, or switch statement. If the break statement includes a label and the statement is executed, control will be transferred out of the enclosing statement to the line immediately following the label declaration. (In this case, the break target need not be a while, do, for or switch statement.)

The break statement also transfers control outside of try/catch blocks. Note that if the break statement with a label is executed within a try or catch block, and an associated finally block is defined for the try/catch block, then the contents of the finally block will first be executed. After the entire finally block has executed, control will once again transfer to the first statement immediately following the label declaration.

The following example demonstrates a break statement used with a label:

block1:

   recordsRemain = getUpdateStatus( );

while (recordsRemain)
{
    if (isRunning)
        System.out.println("Update another record");
    else
        break block1;
}


byte

The byte keyword is used to declare a primitive Java data type containing an integer value in the range of negative 128 to positive 127. A byte is defined as 8 bits in length, regardless of the platform the Java bytecode executes on.

Note that byte variables can be cast to and from other numeric types.

The following example demonstrates declaration and assignment for a byte variable:

private byte stripThis;

stripThis = 64;


case

The case keyword can only be used within a switch statement block. It is used repeatedly to provide any number of unique constants (or numeric labels) for comparison within a switch statement block. If the case constant equals the value of the expression at the top of the switch statement, then control is passed to the statement immediately following the case statement. If, on the other hand, the expression at the top of the switch statement block and the case label do not match, control is passed to the next case for comparison.

In the event that no case constants match the value of the expression given at the top of the switch statement, often a default case is provided.

For an example of how the case keyword can be used, see the keyword switch.


catch

The catch keyword is used to introduce an exception-handling block of code. The keyword is followed by an exception type, an argument name in parentheses, and a block of code to execute should the specified exception actually occur. A try statement and its corresponding block of code always precede a catch statement. When an exception is thrown within the corresponding try statement block, the catch statement's exception type is evaluated to determine whether it is capable of handling the exceptional condition. If the exception type can be handled, the argument is assigned to the specified type and the code within the catch block is executed.

For an example of how the catch keyword can be used, see the keyword try.


char

The char keyword is used to declare a primitive Java data type containing a single 16-bit Unicode character in the range \u0000 to \uffff. Unicode characters are used to represent a majority of known written languages throughout the world. (ASCII characters make up a very small part of the Unicode character set.)

Note that values stored by char may be cast to and from other numeric types. However, because character data is implicitly unsigned, casts of char to byte or short can result in a negative number.

The following example demonstrates declaration and assignment for a char variable:

private char hitChar;

hitChar = 'a';


class

The class keyword is used in the declaration of a new class. A class declaration defines a new reference type (or object) and describes its implementation through the use of constructors, methods, and fields. These implementation details can be inherited from superclasses, or uniquely defined as part of the class declaration.


continue

The continue keyword is used in nested loops to define a continue statement, which, without a label, transfers control to the end of the innermost enclosing while, do, or for loop. Once control is passed, the current loop iteration ends and a new one begins. If the continue statement includes a label and is executed, control is transferred to the last statement of the outer loop. In this case, the continue target label must point to a while, do, or for loop. (Contrast this with the labeled break statement, where the target need not be a loop, or iteration, statement.)

Note that if the continue statement with a label is executed within a try or catch block, and an associated finally block is defined for the try/catch block, then the contents of the finally block will be executed first. After the entire finally block has executed, control will once again transfer to the last statement of the loop immediately following the label declaration.

The following code demonstrates the continue keyword used with and without a label:

block1:
for ( int i = 0; i < 10; i++ )
{
    while ( statusOkay )
    {
        if ( someNum < 0 )
        {
            someNum++;
            System.out.println("Do it again");
            continue;
        }

        if (string1[i] == null)
        {
            System.out.println("null string here");
            continue block1;
        }
        else
        {
            string2[i] = string1[i];
        }
    // continue statement without label points here
    }
// continue statement with label points here
}


default

The default keyword can only be used within a switch statement block. It can be used only once, and is typically located at the end of the switch statement block. The default keyword is used to label statements that are to be executed by default. That is, the default statement block is only executed when the result value of the switch expression does not match any of the case labels within a switch statement block.

For an example of how the default keyword is used, see the keyword switch.


delegate

The delegate keyword is used as part of a delegate declaration to define a class that extends com.ms.lang.Delegate, or com.ms.lang.MulticastDelegate. Delegates are commonly used within the Microsoft Windows Foundation Classes (WFC) library to build event-handling mechanisms.

Delegates roughly equate to function pointers, commonly used in C++ and other object-oriented languages. Unlike function pointers however, delegates are object-oriented, type-safe, and secure. In addition, where a function pointer contains only a reference to a particular function, a delegate consists of a reference to an object, and references to one or more methods within the object.

Either “regular” or multicast delegates may be declared, depending on the presence or absence of the multicast keyword. A “regular” delegate encapsulates a reference to a single method within an instance. When this type of delegate is invoked, the underlying method is called.

A multicast delegate differs from a regular delegate in that it may contain references to more than just one method. Methods in a multicast delegate are executed synchronously when the delegate is invoked, and in the order which they appear. If one of the called methods raises an exception, then the delegate ceases, and the exception is propagated to the delegate caller.

Note The delegate keyword is an extension to the Java language, provided by Microsoft.


do

The do keyword is used as part of a do/while loop. Unlike the other, more commonly used loop constructs, a do/while loop expression is evaluated only after the block of code within its body has been executed. Thus, you are ensured that the code within the loop body is executed at least once, even if the expression tested causes the loop to end.

Note Don't forget that a semicolon is required after the condition in a do/while loop.

The following code shows a typical do/while loop construct:

int i = getValue( );

do
{
    System.out.println("Printing at least once");
    .
    .
    .
} while ( i <= 10 );


double

The double keyword is used to declare a primitive Java data type containing a 64-bit floating-point number in IEEE 754 format. Variables of type double store values in the range negative 1.7E308 to positive 1.7E308 within approximately 14 significant digits of accuracy. When you want a floating-point literal value to be treated as a double, append the letters 'd' or 'D' to the end of the value.

Note that double variables may be cast to and from other numeric types. However, doubles cannot be cast to or from values of type boolean.

The following example demonstrates declaration and assignment for a double variable:

private double dCalcSet;

dCalcSet = 1.23d;
dCalcSet = 3e2;
dCalcSet = .25;


else

The else keyword is used to provide an alternative clause to an if statement. If the expression defined by the if statement evaluates to false, then control transfers to the first statement following the else keyword. If the expression defined by the if statement evaluates to true, then control transfers to the first statement following the if keyword.

Note that if/else conditional testing is a frequent source of program bugs. Consider the following example of a poorly formatted if/else condition:

if ( numPrints < 1000 )
    if ( paperFeed == fullTray )
    {
        printPaperCopy( );
        showStatus( );
        paperFeed--;
    }
else
    suspendPrintJob( ) // Bad indenting!;

In the example shown above, the beginning of the else statement block is formatted to fall into the same column as the outermost if statement, even though it's proper association is with the closest if statement. Problems of this nature can be easily overlooked unfortunately, and it is up to the programmer to use good formatting to illustrate the logical intent of the code.


extends

The extends keyword is used in a class declaration to specify the direct superclass of the class being declared. The superclass can be thought of as the class from whose implementation the implementation of the current class is derived. The class being declared is said to be the direct subclass of the class it extends. If no class is explicitly defined as the superclass with the extends keyword, then that class has the class java.lang.Object as its implicitly declared superclass.

When a class is extended, the class being declared has access to all the public and protected variables and methods of it's superclass. Note that classes declared with the keyword final cannot be subclassed.

The following example shows typical use of the keyword extends:

public class TransactionApplet extends Applet
{
    .
    .
    .
}


false

The false keyword can be used as one of the two possible boolean values. Strictly speaking, false is not a keyword of the Java language; rather, it is a literal value to be assigned to a variable of type boolean.

For an example of how the false keyword can be used, see the keyword boolean.


final

The final keyword is used as a modifier for classes, methods, and variables.

When the final keyword appears in a class declaration, it means that the class may never be subclassed or overridden. This prevents over-specialization of a particular class. In some sense, the person who created the class considered any further changes to be tangential to its primary purpose.

When the final keyword appears in a method declaration, it means that the method may never be overridden. (Note that methods declared with the keywords static or private are implicitly final.)

When the final keyword appears in a variable declaration, it means that the variable has an assigned value that can never be changed.


finally

The finally keyword is used to define a block of code following a try/catch exception block. The finally block is optional, and appears after the try block and after any catch blocks. The code in a finally block is always executed once, regardless of how the code in a try block executes. In normal execution, control reaches the end of the try block and then proceeds to the finally block, which typically performs any necessary cleanup.

Note that if control leaves the try block because of a return, continue, or break statement, the contents of the finally block are still executed before control transfers out of the try block.

If an exception occurs in the try block, and there is an associated catch block to handle the exception within the method, control transfers first to the catch block, and then to the finally block. If there is not a local catch block to handle the exception, control transfers first to the finally block, and then moves up the series of prior method calls until the exception can be handled.


float

The float keyword is used to declare a primitive Java data type containing a 32-bit floating-point number represented in IEEE 754 format. Variables of type double store values in the range positive 3.40282347E+38 to negative 1.40239846E-45. When you want a floating-point literal value to be treated as a float, append the letters 'f' or 'F' to the end of the value.

The following example demonstrates declaration and assignment for a float variable:

float fCalcSet;

fCalcSet = 1.23f;
fCalcSet = 3e2f;
fCalcSet = .25f;


for

The for keyword is used to create a loop construct. An initialization section, an expression section, and an update section immediately follow the keyword. A semicolon separates each section, and all appear together within at least one set of parentheses.

The initialization section allows the programmer to declare one or more local loop variables. Once the loop ends, these variables are no longer valid.

The expression section contains an expression that is evaluated to determine whether the loop should continue. A true result allows the loop to continue; a false result allows control to transfer to the statement following the loop body.

The update section allows the programmer to increment loop counters or perform other updates. Typically, the update section is used to increment or decrement whatever loop counters the programmer defines.

The following example shows a typical for loop construct:

for ( int i = 0; i < 10; i++ )


if

The if keyword is used to execute a statement or block of statements when it's associated expression evaluates to true. An if statement may also have an alternative else clause. If the expression defined by the if statement evaluates to false, then control transfers to the statement (or block of statements) following the else keyword. If the expression defined by the if statement evaluates to true, then control transfers to the first statement following the if keyword.

Note that if/else conditional testing is a frequent source of program errors. Consider the following example of a poorly formatted if/else condition:

if ( numPrints < 1000 )
    if ( paperFeed == fullTray )
    {
        printPaperCopy( );
        showStatus( );
        paperFeed--;
    }
else
    suspendPrintJob( );  // Bad indenting!

In the example shown above, the beginning of the else statement block is formatted to fall into the same column as the outermost if statement, even though it's proper logical association is with the if statement closest to it. Problems of this nature can be easily overlooked, unfortunately and it is up to the programmer to use good formatting techniques to illustrate the logical intent of the code.


implements

The implements keyword is used in a class declaration to indicate that the class provides an implementation for one or more interfaces. If more than one interface is implemented within the class, the interface names must be separated by commas in the declaration. The implements keyword must also follow the extends clause in the class declaration.

The following example demonstrates use of the keyword implements in a class declaration:

public class PotatoHead implements InterchangeableParts
{

}


import

The import keyword is used by Java to make classes available to the current file using an abbreviated name. Any number of import statements may appear in a Java program, but they must appear after the optional package statement at the top of the file, and before the first class or interface definition in the file.

The following examples demonstrate use of the keyword import:

import my.package.*;   // all classes in my.package are imported
import my.package.cool; // only the cool class is imported from my.package


instanceof

The instanceof keyword is used as an operator that returns true if an object on its left side is an instance of the class specified on its right side. The instanceof operator will also return true when comparison is done with an object implementing an interface. The instanceof operator returns false if the object is not an instance of the specified class or does not implement the specified interface. It also returns false if the specified object is null.


int

The int keyword is used to declare a primitive Java data type that contains an integer value in the range of negative 2147483648 to positive 2147483647. An int is defined as 32 bits in length, regardless of what platform the Java bytecode executes on.

The contents of int variables can be cast to or from other numeric types.

The following example demonstrates declaration and assignment for an int variable:

private int iValueK;

iValueK = 1024;


interface

The interface keyword is used in the declaration of an interface. An interface can be thought of as a template for a class that you may need to implement, but you don't have to do all the design work yourself.

Interfaces differ from classes in the following ways:

  • Interfaces cannot implement other interfaces. (They may extend other interfaces.)

  • Interfaces cannot contain constructors, instance variables, class methods, or static class initializers.

  • All methods declared within an interface are implicitly declared to be public and abstract. Methods within an interface cannot be declared as final, native, static, or synchronized.

  • All variables declared within an interface are implicitly declared to be static and final, and thus, must be assigned a constant value. Variables are also implicitly public, and cannot be declared as either transient or volatile.


long

The long keyword is used to declare a primitive Java data type containing a value in the range negative 9223372036854775808 to positive 9223372036854775807. A long is defined as 64 bits in length, regardless of what platform the Java bytecode executes on.

The contents of long variables can be cast to or from other numeric types.

The following example demonstrates declaration and assignment for a long variable:

private long iLedgerBalance;

iLedgerBalance = 1234567890;


multicast

The multicast keyword is used in a delegate declaration to define a class that extends com.ms.lang.MulticastDelegate. For more information on multicast delegates, see the delegate keyword.

Note The multicast keyword is an extension to the Java language, provided by Microsoft.


Reserved Words (M-Z)

native | short | transient
new | static | true
null | super | try
package | switch | void
private | synchronized | volatile
protected | this | while
public | throw |
return | throws |


native

The native keyword is a modifier used in the declaration of a method to indicate that the method is implemented in another programming language. Because a native method is implemented outside of a Java program, the method declaration ends with a semicolon rather than a method body.

Note that native methods cannot be declared with the keyword abstract. For easy access to the Windows API, see Writing Windows-Based Applications with J/Direct.


new

The new keyword is used as an operator for creating a new object or array.

When new is used to create an object, it first creates an instance of the specified class, then initializes all of the instance variables to their default values, and last invokes the appropriate constructor for the class, depending on the arguments provided in the argument list.

Using the new keyword to create a class object typically looks like this:

Button b = new Button("OK");

The new operator can also be used to allocate dimensional arrays for any numeric or object type. Once an array has adequate space allocated, all the elements of the array are initialized to a default value, and it is then up to the programmer to supply values other than the defaults.

Using the new keyword to create an array typically looks like this:

int array[] = new int[ 10 ];


null

The null keyword represents a special value that indicates a variable does not refer to any object. The value null may be assigned to any class or interface variable to aid garbage collection. (Assigning the value null to any of the items above indicates to the garbage collection system that the object or variable is no longer in use.) It cannot be cast to any other type, and should not be considered to have a known numeric value.


package

The package keyword is used by Java to specify which package the code in the file is located in. Java code that is part of a particular package has access to all classes in the package, and all non-private methods and variables in those classes.

The package statement must come before anything else (except comments and conditional compilation directives) in a Java file. If the package statement is omitted from a Java file, the code in that file becomes part of an unnamed default package.


private

The private keyword is a modifier that can be used in the declaration of methods or variables. (Note that the private keyword cannot be used in the declaration of local variables.) Using the private modifier in the declaration for either of these types hides the methods and variables so they cannot be directly referenced outside of the class they're declared in. One exception to this rule is that private methods or variables declared within a class can also be used by inner classes.


protected

The protected keyword is a modifier that can be used in the declaration of methods or variables. (Note that the protected keyword cannot be used in the declaration of local variables.) A protected variable or method is only visible within its class, within its subclasses, or within the class package. Note that the subclasses may reside within different packages, however.


public

The public keyword is a modifier that can be used in the declaration of classes and interfaces. (Note that the public keyword cannot be used in the declaration of local variables.) The public keyword can also be used as a modifier in the declaration of methods and variables. Classes or interfaces declared as public are visible everywhere. Methods and variables declared as public are visible everywhere their corresponding classes are visible.

Note that public classes must have a class name that exactly matches the name of the .java file in which they appear.


return

The return keyword returns control to the invoker of a method or constructor. A return statement used in a method can either return a value, or simply return to the invoker without specifying a value. If a return value from a method is not needed, the return keyword is followed immediately by a semicolon (rather than a value) and the method's declaration must specify a return type of void. If a return value from a method is needed, the method's declaration must specify a return type that matches the type of value being returned.

Note that in constructors, return statements cannot return values.


short

The short keyword is used to declare a primitive Java data type containing a value in the range negative 32768 to positive 32767. A short is defined as 16 bits in length, regardless of what platform the Java bytecode resides on.

The contents of short variables can be cast to or from other numeric types.

The following example demonstrates declaration and assignment for a short variable:

private short squareFeet;

squareFeet = 4600;


static

The static keyword is used as a modifier for methods and variables. The keyword can also be used to define static initializing blocks.

When the static keyword appears in a method or variable declaration, it means that there will be only one copy of the method or variable that each class object may reference, regardless of the number of instances of the containing class that are created.

The static keyword can also be used to create a static initializing block of code that runs only once, when the class object is first loaded into memory.


super

The super keyword is typically used to access hidden variables or overridden methods in a superclass. This keyword can also be used, along with an optional list of arguments, as the first line in a constructor body to call a superclass constructor.


switch

The switch keyword is used along with the keyword case, and sometimes the keyword default, to create a conditional statement. In a switch statement, the switch keyword is followed by an expression within parentheses whose value must evaluate to a primitive Java data type. Once the expression has been evaluated, its value is compared against the label following each case statement within the switch statement body. When a label has the same value, the lines following that case statement are executed. An optional default label is included within the body of a switch statement when there is no guarantee that the labels provided by each case statement are the only values the switch expression may evaluate to.

The following example shows a typical switch statement construct:

switch ( someExpression )
{
    case 1:
        {
        doCase1( );
        break;
        }
    case 2:
        {
        doCase2( );
        break;
        }
    case 3:
        {
        doCase3A( );
        doCase3B( );
        }
    default:
        doDefault( );
}

The break keyword is also, at times, used within the body of a switch statement. Once the lines following a case statement have executed, the break statement is included to jump over the remaining body of the switch condition. Without a break statement, subsequent case statements would continue being evaluated, and eventually the default statement, if one were included, would execute.


synchronized

The synchronized keyword can be used as a modifier to specify thread-safe methods, and as a statement to specify critical sections of code. Used as a method modifier, synchronized indicates that the method should only be available to one thread at a time. Used as a statement, synchronized is followed by an expression in parentheses and a block of statements. If the expression within parentheses evaluates to an object type or array, the program obtains a lock on the item before executing the statement block.


this

The this keyword is used with instance methods and constructors to refer to the current object. Use of the keyword this in the very first statement in the body of a constructor means that another constructor in the same class is being called to assist in creation of the object. For example:

public class MyClass
{

    private long birthday;
    private String name;

    // first constructor
    MyClass( String bDay )
    {
        birthday = formatBirthday( bDay );

    }

    // second constructor
    MyClass(String nm, String bDay )
    {   this ( bDay );

        name = new String(nm);

    }
}

Note The keyword this must appear as the first statement in the body of a constructor, otherwise your code will not compile.

Use of the keyword this in an instance method is helpful when a variable using the same name appears within the method body. For example, when you refer to a class scope variable in a method containing the variable name x, the class scope variable would be known as this.x.


throw

The throw keyword is typically used within a try block to indicate that an exceptional condition has occurred. The throw keyword is followed by an exception object, derived from the class Throwable, indicating the type of exception being thrown. A throw statement causes a program to immediately stop and resume at the nearest catch statement that can handle the specified exception object. Hence, throw statements may also be outside a try block, if the exception will be caught elsewhere within the program.

The following example shows use of the throw keyword:

public void someMethod( int div ) throws Exception1
{
    try
    {
        if ( div == 0 )
            throw new Exception1( );
    }
    catch(Exception1 e1)
    {
        // Exception can be handled in this catch
        // block
        .
        .
        .
    }
}


throws

The throws keyword is used in a method declaration to list any exceptions not derived from Error or RuntimeException that a method can throw. (Exceptions derived from type RuntimeException are typically avoidable. Exceptions derived from type Error are usually related to serious system problems; thus, little can be done about them.)

The following example shows a typical method declaration using the throws keyword:

public int someMethod( int argument ) throws Exception1, Exception2
{
    // This method may contain a try/catch block
    // for detecting and possibly handling any caught
    // exceptions.

}


transient

The transient keyword is a modifier used in the declaration of variables. Use of this keyword specifies that the current value of the variable need not be serialized (or saved) along with other data stored in a class object.

The following example shows the declaration of a variable with the transient modifier:

private transient int currentTime;


true

The true keyword can be used as one of the two possible boolean values. Strictly speaking, true is not a keyword of the Java language; rather, it is a literal value that is assigned to a variable of type boolean.

For an example of how the true keyword can be used, see the keyword boolean.


try

The try keyword is used to indicate a block of code in which an exception might occur. For each try statement, there must be at least one corresponding catch clause. If the exception occurs, the catch clause parameter is evaluated to determine whether it is capable of handling the exceptional condition. If the exceptional condition cannot be handled by any of the catch clauses corresponding to the try statement, then control is transferred up the chain of method calls and all the previous exception types are evaluated until one capable of handling the condition is found.

Note that if the try statement has a corresponding finally clause, then the body of the finally clause will be executed no matter whether the try block completes normally or abruptly, and no matter whether a catch clause is first given control.

The following example shows a typical try/catch/finally construct:

try
{
    // code within this block may cause an exception.
    .
    .
    .
}
catch( Exception1 e1 )
{
    // code within this block is executed only
    // when an exception of type Exception1 occurs,
    // otherwise it is skipped over.
    .
    .
    .
}
catch( Exception2 e2 )
{
    // code within this block is executed only
    // when an exception of type Exception2 occurs,
    // otherwise it too is skipped over.
    .
    .
    .
}
finally
{

    // code within this block is always executed,
    // regardless whether an exception within the
    // try block occurs or not. This block is
    // typically used for cleaning up.
    .
    .
    .
}


void

The void keyword is used in the declaration of a method to indicate that the method returns no value.

Note that Java provides only this very limited use of the void keyword. Unlike in the C language, the void keyword cannot be used to declare the absence of method parameters, void pointers, and so on.


volatile

The volatile keyword is a modifier used in the declaration of variables. Use of this keyword specifies that the value the variable contains may change asynchronously, and, therefore, the compiler should not attempt to perform optimizations with it.


while

The while keyword is used to create a loop construct. In a while loop, the expression in parentheses immediately following the keyword is evaluated, and if the boolean result is true, the statements appearing within the loop body are executed. If multiple statements make up the body of the loop, they must be enclosed with curly braces. Once the loop body has executed, control transfers back to the top of the loop where the test is performed again, and the execution of the loop body is repeated until the value of the expression evaluates to false.

The following example shows a typical while loop construct:

while ( i < 10 )
{
    // statements here execute if above expression is true
    .
    .
    .
}


Compiler Error J0001

INTERNAL COMPILER ERROR:

The compiler was unable to recover after detecting an error. Please consult your technical support help file, available from the Help menu, for instructions on how to search the Microsoft Knowledge Base for the latest information on this problem. Also, try to simplify the code where the compiler reported this error and compile again.


Compiler Error J0002

Out of memory

The compiler attempted to allocate some additional memory during processing, but was unable to do so. Check the location, size, and validity of your system swap file. Also, ensure that there is sufficient growth space available on the drive on which your swap file resides.


Compiler Error J0004

Cannot open class file 'filename' for reading

The compiler could not open the program source file for reading. This error usually occurs when another program has an exclusive lock on the source file. Close other processes that may be accessing the source file and compile again.


Compiler Error J0005

Cannot open class file 'filename' for writing

The compiler failed to generate the output .class file. This error usually occurs when the compiler cannot get write or create permission for the file. Ensure the file does not have its read-only attribute set, and that it is not currently in use by another process. This error can also occur when you are running or debugging the program that contains the specified .class file. Close all instances of the program and compile again.


Compiler Error J0006

Cannot read class file 'filename'

The compiler failed to read the specified .class file. This error usually occurs when the compiler encounters an error reading the storage device, or when the compiler cannot otherwise get read permission for the file. Ensure that the file is not in use by another process. Also, ensure the validity of the storage device you are attempting to use by using a disk scanning utility.


Compiler Error J0007

Cannot write class file 'filename'

The compiler failed while attempting to write the contents of a buffer to the specified .class file. This error usually occurs when space is exhausted on the targeted storage device. Free up any available space on the storage device and compile again.


Compiler Error J0010

Syntax error

The compiler could not determine the meaning of an expression or statement within the source program. This error usually occurs when the line, indicated in the error message, is syntactically invalid. This error typically accompanies a more descriptive error. Correct any accompanying errors and compile again.

The following example illustrates this error:

public class Simple {

   public void method1() {
      int i =; // error: missing assignment value
   }
}


Compiler Error J0011

Expected ':'

The compiler expected to find a colon following a case label or in a conditional expression that makes use of the ternary operator. This error usually occurs when a colon is accidentally omitted. Many times this error is caused on the line previous to the line the compiler has reported the error on. Ensure that the lines that require a colon are correct and compile again.

The following example illustrates this error:

public class Simple {

   private int i;
   private static int x = 1;

   public void method1(int arg1) {

      switch (arg1) {
         case 1 // error: ':' omitted after 'case 1'
      }

      i = ( arg1 < x) ? arg1  x; // error: ':' omitted after 'arg1'
   }
}


Compiler Error J0012

Expected ';'

The compiler expected to find a semicolon in the position indicated by the error message. This error usually occurs when the semicolon is accidentally omitted from the end of a statement. It can also occur when a conditional expression is not syntactically correct. This error is often caused on the line previous to the line the compiler has reported the error on. Ensure that semicolons are used properly and compile again.

The following example illustrates this error:

public class Simple {

   private static int x = 10 // error: ';' omitted

   public void method1(int arg1) {

      for (int i = 1; i < x i++) {
         // error: ';' omitted
      }
   }
}


Compiler Error J0013

Expected '('

The compiler expected to find a left parenthesis in the position indicated by the error message. This error usually occurs when the left parenthesis is accidentally omitted in any of the following situations:

  • Type initializations

  • catch statements

  • Parenthesized expressions

  • while loops

  • for loops

  • if/else statements

The following example illustrates this error:

public class Simple {

   private int i;

   public void method1(int arg1, int arg2) {

      if arg1 < arg2) // error: '(' omitted
         i = arg1;
      else
         i = arg2;

   }
}


Compiler Error J0014

Expected ')'

The compiler expected to find a right parenthesis in the position indicated by the error message. This error usually occurs when the right parenthesis is accidentally omitted in any of the following situations:

  • Type initializations

  • Type casts

  • catch statements

  • Parenthesized expressions

  • while loops

  • for loops

  • if/else statements

The following example illustrates this error:

public class Simple {

   private int i;

   public void method1(int arg1, int arg2) {

      i = (arg1 < arg2 ? arg1 : arg2;
      // error: ')' omitted
   }
}


Compiler Error J0015

Expected ']'

The compiler expected to find a right square bracket in the position indicated by the error message. This error usually occurs when the right square bracket is accidentally omitted from an array declaration. This error is often caused on the line previous to the line the compiler has reported the error on. Ensure that all brackets match and compile again.

The following example illustrates this error:

public class Simple {

   private int x[ = new int[500]; // error: ']' omitted

}


Compiler Error J0016

Expected '{'

The compiler expected to find a left brace in the position indicated by the error message. This error usually occurs when the left brace is accidentally omitted from the beginning of a class declaration or method code block. This error is often caused on the line previous to the line the compiler has reported the error on. Ensure that all braces match and compile again.

The following example illustrates this error:

public class Simple // error: '{' omitted

   public void method1() {
      // do something meaningful
   }
}


Compiler Error J0017

Expected '}'

The compiler expected to find a right brace in the position indicated by the error message. This error usually occurs when a class or method’s closing brace is not found. This error is often caused on the line previous to the line the compiler has reported the error on. Ensure that all braces match and compile again.

The following example illustrates this error:

public class Simple {
{
   int x,y;
   //error: no matching brace found for class


Compiler Error J0018

Expected 'while'

The compiler expected to find the keyword while in the position indicated by the error message. This error usually occurs when a do/while loop is not syntactically correct.

The following error illustrates this error:

public class Simple{
   public void method1(){
      do{
          // do something useful here
      }; //error: missing 'while' statement
}

The following code illustrates the correct form of a do/while loop:

public class Simple{
   public static void method1(){
      int x = 10;
      do{
        System.out.println(x);
        x--;
      }while(x != 0); //this is correct form for do/while loop
   }
   public static void main(String args[]){Simple.method1();}
}


Compiler Error J0019

Expected identifier

The compiler expected to find an identifier before the name of a class, interface, variable, or method declaration. This error usually occurs when the type is accidentally omitted in a declaration.

The following example illustrates this error:

public class Simple {

   private i;  // error: type omitted

}


Compiler Error J0020

Expected 'class' or 'interface'

The compiler expected to find either class or interface used within the corresponding declaration. This error usually occurs when the keywords are accidentally omitted from a class or interface declaration. Another possible cause of this error is unbalanced scoping braces.

The following example illustrates this error:

public Simple{ //error: missing the 'class' keyword
   //Do something here
}

This example illustrates this error caused by unbalanced scoping braces:

public class Simple {

   // do something meaningful

}}   // error: additional '}' not needed


Compiler Error J0021

Expected type specifier

The compiler expected to find a type specifier in the position indicated by the error message. This error usually occurs when a typographical error exists in an object instantiation or variable declaration.

The following example illustrates this error:

public class Simple {

   public Object o =new; //error: missing 'Object' type specifier
}


Compiler Error J0022

Expected end of file

The compiler expected to encounter an end-of-file character, but did not. This error usually occurs when the source file has been damaged in some way. Visually check the source file for obvious corruption, save any changes, and compile again.


Compiler Error J0023

Expected 'catch' or 'finally'

The compiler expected to find a catch or finally block immediately following a corresponding try block.

The following example illustrates this error:

public class Simple {
   public void method1(){
      try {
         // do something meaningful
      }
   } // error: 'catch' or 'finally' not found
}

The following example illustrates the correct syntax for using a try/catch block:

public clas Simple{
   public void method1(){
      try{
        //Do something here. Possibly throw an exception type
      }
      catch(Exception e){
         /*Handle any errors here and use the 'Exception' object to
         determine the type of error that occurred */
      }
   }
}


Compiler Error J0024

Expected method body

The compiler expected to find a method body immediately following a method declaration. This error usually occurs when the braces surrounding the method body are missing. This error can also occur when the method was intended to be abstract or native, but the abstract or native keyword was mistakenly omitted from the method declaration.

The following example illustrates this error:

public abstract class Simple {

   public void method1();
   // error: 'abstract' omitted
   // This error would also exist if the class is not declared 'abstract'

}


Compiler Error J0025

Expected statement

The compiler expected to find a statement before the end of the current scope. This error usually occurs when the left brace, designating the beginning of the current scope, or both left and right braces are missing. Ensure that the braces for the current scope are balanced.

The following example illustrates this error:

public class Simple {

   void method1(int arg1) {

      if (arg1==1)
      // error: missing the left brace for the if statement
   }
}


Compiler Error J0026

Expected Unicode escape sequence

The compiler expected to find a valid Unicode escape sequence. This error usually occurs when a backslash is not followed by the letter "u" to signify a Unicode escape sequence. Check the syntax of your Unicode escape sequence and compile again.

The following example illustrates this error:

public class Simple {

   int i = \\u0032;
   // error: '\\' not valid

}


Compiler Error J0027

Identifier too long

The compiler detected an identifier name with a length greater than 1024 characters. Shorten the identifier name and compile again.


Compiler Error J0028

Invalid number

The compiler detected a numeric value that the Java language is not capable of supporting. This error usually occurs when the number specified is an amount that is outside of the range of any of Java's primitive data types. This error usually occurs when a numerical value is too large to be stored in the specified data type.

The following example illustrates this error:

public class Simple {

   long i = 12345678901234567890;
   // error: value out of range for 'long'

}


Compiler Error J0029

Invalid character

The compiler detected an ASCII character that could not be used in an identifier. This error usually occurs when a class, interface, method, or variable identifier includes an invalid character.

The following example illustrates this error:

public class Simple {

   private int c#;
   // error: '#' not supported

}


Compiler Error J0030

Invalid character constant

The compiler detected an attempt to assign an invalid character or character escape sequence to a variable of type char.

The following example illustrates this error:

public class Simple {

   char c = '\';
   // error: invalid escape character
   char x = '\\'; \* correct assignment of the backslash to the char
                     variable */
}


Compiler Error J0031

Invalid escape character

The compiler detected the use of an invalid escape character. This error usually occurs when a syntactical error is found in a Unicode escape sequence. The error can also occur if you use a "\" character in a string assignment.

The following example illustrates this error:

public class Simple {

   int i = \u032;
   // error: Unicode uses 4 hex digits
   int x = \u0032;
   //correct assignment of a Unicode escape sequence

}

The following example illustrates the error being caused by assigning the "\" character improperly to a string:

public class Simple{

   public String str = "C:\Windows\Desktop";
   //error: invalid assignment of the '\' character to a string
   //To assign it correctly use the '\\' character assignment
}


Compiler Error J0032

Unterminated string constant

The compiler did not detect a terminating double-quote character at the end of a string constant. This error usually occurs when the string terminator is accidentally omitted, or when the string constant is mistakenly divided onto multiple lines.

The following example illustrates this error:

public class Simple {

   String str = "Hello;
   // error: closing quote omitted

}


Compiler Error J0033

Unterminated comment

The compiler detected the beginning of a block comment, but did not detect a valid ending. This error usually occurs when the comment terminator is accidentally omitted.

The following example illustrates this error:

public class Simple {

   /* This comment block
    * does not have a valid
    * terminator

}


Compiler Error J0035

Initializer block cannot have modifiers except 'static'

The compiler detected a modifier other than static associated with an initializer. Use only the static keyword to specify the initializer as a static initializer or no modifier to signify that the initializer is an instance initializer. Remove the modifier from the initializer specified in the error message or add the static modifier to the initializer and compile again.

The following example illustrates this error:

public class Simple {
   protected{   // error: 'protected' is invalid here
      //do something here
   }
}


Compiler Error J0036

A data member cannot be 'native', 'abstract', or 'synchronized'

The compiler detected one of the modifiers shown above used in the declaration of a variable. The modifiers synchronized and native can only be applied to method declarations. The abstract modifier can be applied to methods, classes, and interfaces.

The following example illustrates this error:

public class Simple{

   native int myvar1;
   abstract int myvar2;
   synchronized int myvar3;
   //error: the vars above have invalid modifiers

}


Compiler Error J0037

A method cannot be 'transient' or ‘volatile’

The compiler detected one of the modifiers shown above used in the declaration of a method. The modifiers transient and volatile can only be applied to field declarations.

The following example illustrates this error:

public class Simple{

   transient void Method1(){};
   volatile void Method2(){};
   //error: the methods above have invalid modifiers

}


Compiler Error J0038

'final' member ‘identifier’ must be initialized when declared in an interface

The compiler detected an uninitialized final variable in an interface definition. Variables declared as final in an interface definition must have their value set at declaration. Once set, the value cannot be programmatically changed.

The following example illustrates this error:

interface ISimple {

   final int COOL_RAD;
   // error: must have value set

}


Compiler Error J0040

Cannot define a method body for abstract/native methods

The compiler detected a method body defined immediately following the corresponding declaration of an abstract or native method. An abstract method must have it's implementation code defined in a subclass. Native methods are implemented using code from a native language such as C++.

The following example illustrates this error:

public abstract class Simple{
   abstract void method1(){
      //Do something here
   }//error: abstract methods are implemented in subclasses
}

Methods declared within an interface are implicitly abstract. As such, this error can also occur when you attempt to define a method body in an interface. The following code illustrates this scenario:

public interface Simple {

   public void method1() {
      // error: must define this method body
      // in a class that implements the
      // 'Simple' interface
   }
}


Compiler Error J0041

Duplicate modifier

The compiler detected a modifier used twice in a declaration. This error usually occurs when the same modifier is mistakenly used more than once within a declaration.

The following example illustrates this error:

public class Simple {

   public public void method1() { // error: 'public' used twice
      // do something meaningful
   }
}


Compiler Error J0042

Only classes can implement interfaces

The compiler detected an interface declaration using the implements keyword. Interfaces cannot implement other interfaces. Interfaces can only be implemented by classes. This error usually occurs when an interface is mistakenly implemented instead of extending another interface using the extends keyword.

The following example illustrates this error:

public interface Simple implements color{
   // error: 'Simple' cannot implement the
   // 'color' interface

}
interface color {
   // do something meaningful
}

interface pattern extends color{
   //extending an interface is OK here
}


Compiler Error J0043

Redeclaration of member 'identifier'

The compiler detected the same identifier name being declared more than once within the same scope. This error usually occurs when a variable or method is mistakenly declared more than once. Ensure that you have not declared a method or variable more than once in the same class. Methods can have the same name but must differ in method parameters in order to be different.

The following example illustrates this error:

public class Simple {
   private int i;
   public void method1(){
      //do something here
   }

   //Other declarations for the class go here

   private int i; // error: 'i' declared twice
   public void method1(){
      //error: method declared twice
   }
}


Compiler Error J0044

Cannot find definition for class 'identifier'

The compiler could not locate the definition for the specified class. This error is usually caused by a typographical error. It can also occur when the package containing the specified class cannot be found.

The following example illustrates this error:

class NotSimple{
   //do something here
}

public class Simple {

   NotSimple smp = new NotSmple();
   // error: 'NotSmple' not a valid class name

}


Compiler Error J0045

'identifier' is not a class name

The compiler detected one of the following conditions:

  • A class name provided as part of an import statement could not be found.

  • The import statement was not syntactically valid.

  • The class attempted to extend an interface. Only classes can be used with the extends statement.

  • Ensure that that the package exists and that any classes you import exist in the package specified in the import statement and compile again.

The following example illustrates this error:

package non.existent;
import non.existent; /* error: the package is not existant and cannot be
                        imported */

public class Simple {

   // do something meaningful

}


Compiler Error J0046

'identifier' is not an interface name

The compiler detected that the identifier referred to by the keyword implements is not an interface. This error usually occurs when a class is used instead of an interface in an implements statement.

The following example illustrates this error:

class Simple2 {

   // do something meaningful

}

public class Simple implements Simple2 {

   // error: cannot implement class ‘Simple2’

}


Compiler Error J0048

Cannot extend final class 'identifier'

The compiler detected an attempt to subclass a class declared with the keyword final. Classes declared as final cannot be subclassed.

The following example illustrates this error:

final class Simple2 {

   // do something meaningful

}

public class Simple extends Simple2 {

   // error: cannot extend ‘Simple2’

}


Compiler Error J0049

Undefined name 'identifer'

The compiler detected a reference to a class, method, or variable that does not exist. Examples of when this error can occur include:

  • A variable is referenced that does not exist or is mistyped.

  • The object used with a method call does not exist or is mistyped.

  • A class is imported that does not exist in the package specified or is mistyped.

Ensure that the reference to the class, method, or variable displayed in the error message is correct and compile again.

The following example illustrates this error:

import java.io.bogus; // error: unknown class name

public class Simple {

   public int method1(){
      return novar1;
      //error: 'novar1' does not exist
   }
   public void method2(){
      NotSimple nt = new NotSimple();
      np.methodx();
      //error: the object reference 'np' should be 'nt'
}

class NotSimple{
   public void methodx(){
      //do something meaningful here
   }
}


Compiler Error J0051

Undefined package 'identifier'

The compiler detected a package name declaration, but was unable to locate the package definition. This error usually occurs when a syntactical error exists in an import statement. This error may also occur when the package cannot be found or does not exist.

The following example illustrates this error:

import java.lang.bogus.*;
// error: ‘bogus’ not a valid package name

public class Simple {

   // do something meaningful

}


Compiler Error J0053

Ambiguous name: 'identifier' and 'identifier'

The compiler could not resolve an ambiguity between the two identifiers shown. This error usually occurs when the same class name appears in two packages that are both imported into a source file using the "*" class import specifier. Ensure that you do not have two classes with the same name in the packages you are importing into your source file and compile again.


Compiler Error J0056

Missing return type specification

The compiler detected a method declaration without a return type specified. All method declarations must specify a return type. If the method is not meant to return a value, use the void keyword.

The following example illustrates this error:

public class Simple {

   public method1() { // error: no return type

      // do something meaningful
   }
}


Compiler Error J0057

Class file 'identifier' should not contain class 'identifier'

This compiler did not detect the class specified in the error in the specified class file. This error usually occurs when a class is compiled into a class file that later is renamed. Because the class file has a different name than the class contained inside of it, attempting to use the name of the class file as a class will fail. To avoid this situation you will need to change the class definition to have the correct name or rename the file back to the original class name.


Compiler Error J0058

Cannot have a variable of type 'void'

The compiler detected a variable declared as type void. The keyword void is not allowed in variable declarations. Rather, void can only be used as a method return type, noting that the method does not actually return a value.

The following example illustrates this error:

public interface Simple {

   public final static void i = 1;
   // error: 'void' not valid
}


Compiler Error J0059

Cannot reference member 'identifier' without an object

The compiler detected an attempt to reference a variable without a known object association. This error usually occurs when an instance field or method (a field or method declared without the keyword static) is referenced from within a static method without a valid instance. Static methods cannot use instance fields and methods without a valid instance of the class.

The following example illustrates this error:

public class Simple {

   private int x;
   public void method1(){
      //Do something here
   }
   public static void main(String args[]) {

      x = 0; /* error: 'x' must be static or referenced using class
                instance */
      method1(); /* error: 'method1' must be static or referenced with
                           a class instance */
   }
}

The following example illustrates the correct method to refer to a non-static member field or method:

public class Simple{

   private int x; //access level of member does not matter
   public void method1(){
      //Do something here
   }
   public static void main(String args[]){
      //Create an instance of the 'Simple' class
      Simple smp = new Simple();
      smp.x = 0; //valid reference to field
      smp.method1(); //valid call to method
   }
}


Compiler Error J0060

Invalid forward reference to member 'identifier'

The compiler detected an attempt to initialize a variable with another variable that had not yet been defined. To avoid this situation, reverse the field declarations order so that a variable that is referenced by another is defined first.

The following example illustrates this error:

public class Simple {
   private static int i = j;
   // error: 'j' not yet defined
   private static int j = 0;
}

The following shows the correct way to initialize a field using another field in the same class:

public class Simple{
   private static int j = 0; //field is instantiated and populated
   private static int i = j; //with 'j' properly set, 'i' can be set
}


Compiler Error J0061

The members 'identifier' and 'identifier' differ in return type only

The compiler detected a subclass method attempting to overload a base class method, but the methods differed only in return type. In Java, overloaded methods must be distinguished by unique signatures. A unique signature consists of the method name, the number, type and positions of its parameters, and the return type.

The following example illustrates this error:

public class Simple extends Simple2 {

   public void method1() {
      // error: only return type differs
   }
}

class Simple2 {

   public int method1() {

      return 1;
   }
}


Compiler Error J0062

Attempt to reduce access level of member 'identifier'

The compiler detected an overridden method in the class being compiled that reduces the access level of its base class method. The base class access modifier for a method must be maintained by all derived classes that wish to overload the method.

The following example illustrates this error:

public class Simple{
   public void method1(){
      //Do something here
   }
}

class Simple2 extends Simple{
   private void method1(){
      /*error: cannot change access level of a method
      when overriding a base class's method. */
   }
}


Compiler Error J0063

Declare the class abstract, or implement abstract member ‘identifier’

The compiler detected an abstract method defined in a class, a superclass, or an implemented interface but the method was never implemented. This error usually occurs when a class implements an interface or extends a class that contains an abstract method definition, but the class never implements the abstract method. This error can also occur if a class defines an abstract method but the class does not have the abstract modifier defined. Ensure that your class has implemented any abstract methods and compile again.

The following example illustrates this error:

interface ITest{
   public abstract void method1();
}

public class Simple implements ITest{
   //Do something meaningful here
   //error: the abstract method defined in 'ITest' is never implemented
}


Compiler Error J0065

Cannot assign to this expression

The compiler detected an expression in the position normally held by an lvalue for assignment. This error usually occurs when an expression is being assigned a value but the expression is not capable of accepting the assignment.

The following example illustrates this error:

public class Simple {

   public void method1() {

      int x = 0;
      int y = 1;

      x++ = y; //error: '++' not valid
   }
}


Compiler Error J0066

'this' can only be used in non-static methods

The compiler detected use of the keyword this within a class (or static) method. Class methods are not passed implicit this references. As such, they cannot reference instance (non-static) variables or methods.

The following example illustrates this error:

public class Simple {

   int x;

   public static void method1() {

      this.x = 12; // error: 'this' instance specific
   }
}


Compiler Error J0067

Cannot convert 'type' to 'type'

The compiler detected a variable type used out of its correct context. As such, the compiler could not implicitly convert the result to anything meaningful. Convert the value you are attempting to use to something the method or field definition requires and compile again.

The following example illustrates this error:

public class Simple {

   public void method1() {

      int i = 10;

      if (i--) {
         // error: conditional needs expression
         // or boolean field
      }
   }
}


Compiler Error J0068

Cannot implicitly convert 'type' to 'type'

The compiler could not convert the specified variable without an explicit typecast. This error usually occurs when a numerical field is assigned to a data type that is not numerical. Use a typecast to convert the data type to the appropriate data type and compile again.

The following example illustrates this error:

public class Simple {

   int i = 10;

   public void method1() {
      char c = i; // error: expected type char
      char c = (char)i; // this is the correct assignment statement
   }
}


Compiler Error J0069

Cannot apply '.' operator to an operand of type 'identifier'

The compiler detected the '.' operator applied to an invalid type. This error usually occurs when an invalid method call is made on an intrinsic data type. Ensure that your method call is using the correct object and compile again.

The following example illustrates this error:

public class Simple {

   int i = 123;
   int j = i.length; // error: 'i' not an array

}


Compiler Error J0072

'identifier' is not a member of class 'identifier'

The compiler detected a method call, but the method is undefined. This error usually occurs when the method name is either misspelled or cannot be found within the proper scope. This error can also occur when the method does not exist. Ensure that the member you are trying to reference exists in the specified class and compile again.

The following example illustrates this error:

public class Simple {

   public static void main(String args[]) {

      System.out.printline("Hello");
      // error: 'printline' should be 'println'
   }
}


Compiler Error J0074

Operator cannot be applied to 'identifier' and 'identifier' values

The compiler detected an operator that cannot be correctly applied to the identifiers shown in the error message. This error usually occurs when two fields are non-numerical and operators used for numbers are applied to the fields.

The following example illustrates this error:

public class Simple {

   public void method1() {

      String s1 = "one";
      String s2 = "two";
      String result;

      result = s1 * s2; // error: invalid operands
   }
}


Compiler Error J0075

Invalid call

The compiler detected syntax for a method call, but the identifier does not represent a valid method name. This error usually occurs when a method name is misspelled or contains characters that are not recognized as valid in the Java language naming conventions.

The following example illustrates this error:

class Simple {
   int x = 1();
   //error: '1()' is not a valid method name
}


Compiler Error J0076

Too many arguments for method 'identifier'

The compiler detected a known method call, but the call contained more arguments than needed. Check the number of arguments for the method you are attempting to call and remove any additional arguments from the call.

The following example illustrates this error:

public class Simple {

   public void method1(int arg1) {

      // do something meaningful
   }

   public void method2() {

      method1(1, 2); // error: Too many arguments
   }

}


Compiler Error J0077

Not enough arguments for method 'identifier'

The compiler detected a known method call, but the call contained fewer arguments than needed. This error usually occurs when one or more arguments are accidentally omitted from the call.

The following example illustrates this error:

public class Simple {

   public void method1(int arg1) {
      // do something meaningful
   }

   public void method2() {

      method1(); // error: Too few arguments
   }
}


Compiler Error J0078

Class 'identifier' doesn’t have a method that matches 'identifier'

The compiler identified a call to a known overloaded method within another class, but was unable to detect a matching method with the correct number of arguments. Ensure that the overloaded method call has the correct number and type of arguments and compile again.

The following example illustrates this error:

public class Simple {

   public void method1() {
      // do something meaningful
   }

   public void method1(int arg1) {
      // do something meaningful
   }
}

class Simple2 {

   public void method1() {

      Simple s = new Simple();
      s.method1(1, 2, 3); // error: too many arguments
   }
}


Compiler Error J0079

Ambiguity between 'identifier' and 'identifier'

The compiler could not distinguish the correct method to execute. This error usually occurs when two overloaded methods have related argument lists and the method call cannot be differentiated between the two methods. Ensure your method call is not using a parameter that conflicts with another overloaded method. Another way to avoid this error is to change the argument lists of the two overloaded methods so that they have a different number of arguments or more uniquely defined parameter data types.

The following example illustrates this error:

public class Simple {

   static void method1(Simple2 s2, Simple3 s3) {
      // do something meaningful
   }

   static void method1(Simple3 s3, Simple2 s2) {
      // do something meaningful
   }

   public static void main(String args[]) {

      Simple2 s2 = new Simple2();
      method1(s2, s2);
      // error: Ambiguity between Simple2 and Simple3
   }
}

class Simple2 extends Simple3 {
   // do something meaningful
}

class Simple3 {
   // do something meaningful
}


Compiler Error J0080

Value for argument 'identifier' cannot be converted from 'identifier' in call to 'identifier'

The compiler detected a method argument that does not match the parameters specified in the method declaration. This error usually occurs when a numerical field is passed as an argument to a method but the method requires a different numerical type. To pass different numerical types to arguments of a method, typecast the field being passed to the method.

The following example illustrates this error:

public class Simple {

   public void method1(int arg1) {
      // do something meaningful
   }

   public void method2() {

      float f = 1.0f;
      method1(f); // error: mismatched call types
   }
}

The following example illustrates how to avoid this error:

public class Simple{
   public void method1(int arg1){
      //do something meaningful
   }

   public void method2(){
      float f = 1.0f;
      method1((int)f); //typecast the 'float' to be treated as an 'int'
   }
}


Compiler Error J0081

Value for argument 'identifier' cannot be converted from 'identifier' in call to 'identifier'

The compiler detected a call to a method in a class located in a different class file, but was unable to convert one of the arguments from the supplied type to the type shown in the method declaration. This error usually occurs when a method is called with the arguments in the wrong order or the wrong method was called. Check the argument number that caused the error in the error message and ensure you passed the correct type of argument.


Compiler Error J0082

Class 'identifier' doesn't have a constructor that matches 'identifier'

The compiler did not detect a constructor matching the call identified in the error. This error usually occurs when a constructor is called with the wrong number of arguments. Ensure that the class has a constructor that matches the one you are attempting to call and compile again.

The following example illustrates this error:

public class Simple {

   Simple(int arg1) {
      // do something meaningful
   }

   public static void main (String args[]) {

      Simple s = new Simple(12, 13);
      // error: too many arguments
   }
}


Compiler Error J0083

'super()' or ‘this()’ may only be called within a constructor

The compiler detected use of either the super() or this() keyword outside of a constructor. The super() keyword is used to call a superclass constructor, while the this() keyword is used to call one constructor from another. To reference methods in a base class you must use the super. keyword.

The following example illustrates this error:

public class Simple {

   public void method1 () {

      super(); // error: 'super' cannot be called
   }
}

The following example illustrates using the super. keyword to reference a method in a base class:

class NotSimple{
   public class method1(){
      //do something here
   }
}

public class Simple{
   public method2(){
      super.method1(); //correct way to call a method of a superclass
   }
}


Compiler Error J0084

Cannot return a value from a 'void' method

The compiler detected an attempt to return a value from a method declared with a return type of void.

The following example illustrates this error:

public class Simple {

   public void method1() {
      return 1; // error: cannot return a value
   }
}


Compiler Error J0085

Expected return value of type 'identifier'

The compiler detected the keyword return within the body of a method which was declared to return a specific type, but the return had no associated value. The return statement with no associated value will not return a default value and thus must be assigned a valid return value.

The following example illustrates this error:

public class Simple {

   public int method1() {
      return; // error: must return int value
   }
}


Compiler Error J0086

'[]' cannot be applied to a value of type 'identifier'

The compiler detected array brackets used with a non-array type. Change the field to be a valid array declaration if you want to use the field as an array and compile again.

The following example illustrates this error:

public class Simple {

   public void method1() {
      int i = 0;
      int j, x;

      x = j[i]; // error: ‘j’ not declared as array
   }
}


Compiler Error J0087

'goto' statement is not currently supported by Java

The keyword goto, while defined as a keyword, has not yet been implemented in the Java language.


Compiler Error J0089

The case 'identifier' has already been defined in switch statement

The compiler identified two or more case statements with the same identifier or value occurring within the same switch statement.

The following example illustrates this error:

public class Simple {

   public int method1(int arg1) {

      switch (arg1) {
         case 1:
            return (int) 1;
         case 2:
            return (int) 2;
         case 2: // error: duplicate of above
            return (int) 3;
         default:
            return (int) 0;
      }
   }
}


Compiler Error J0090

'default' has already been defined in switch statement

The compiler identified two or more instances of the keyword default occurring within the same switch statement.

The following example illustrates this error:

public class Simple {

   public int method1(int arg1) {

      switch (arg1) {
         case 1:
            return (int) 1;
         case 2:
            return (int) 2;
         default:
            return (int) 3;
         default: // error: duplicate of above
            return (int) 0;
      }
   }
}


Compiler Error J0091

'case' outside of switch statement

The compiler identified the keyword case used outside the scope of a switch statement.

The following example illustrates this error:

public class Simple {

   public int method1() {
      case 1: // error: no switch statement
         return 1;
   }
}


Compiler Error J0092

Constant expression expected

The compiler detected an expression that used a non-constant value when a constant value was required. This error usually occurs when a variable is used in a case statement. Check the expression to be sure that a constant value is being used and compile again.

The following example illustrates this error:

public class Simple{
   int var1 = 10;
   int var2 = 20;
   public void method1(){
      switch(var1){
        case var2:
        //error: cannot use variable with case
      }
   }
}


Compiler Error J0093

'break' only allowed in loops and switch statements

The compiler detected the keyword break occurring outside the scope of a loop or switch statement.

The following example illustrates this error:

public class Simple{
   public void method1(){
      if (true)
         break;
         //error: break allowed in loops only
   }
}


Compiler Error J0094

Label 'identifier' not found

The compiler detected a label name associated with one of the keywords continue or break, but could not find the label. This error usually occurs when a label does not exist, yet it is being referenced by a break or continue statement. This error can also occur if the label is placed outside the break or continue statement's scope. A break or continue statement must reference a label that precedes an enclosing loop or block. Ensure that the break or continue statement can access a valid label and compile again.

The following example illustrates this error:

public class Simple{
   public int method1(){
      int y;
      for (int x = 0; x < 10; x++){
         y = x *2;
         if (x == 5)
            break test; //error 'test' is not defined as a label
      }
      return y;
   }
}

The following example illustrates the correct usage of a label when used with the break or continue statements:

public class Simple{
   public int method1(int arg1){
      int x,y = 0;
      test: //label precedes the loop.
      if (arg1 = 0)
         return y;
      for (x=1; x < 10; x++){
         y = x * arg1;
         if (y <= arg1){
            y = -1;
            break test;
         }
      }
      return y;
   }
}


Compiler Error J0095

'continue' only allowed in loop

The compiler detected attempted use of the keyword continue outside the scope of a loop. This error usually occurs when a loop is removed and continue statements are left in the code. Remove any continue statements that are outside of a loop and compile again.

The following error illustrates this error:

public class Simple{
   public void method1(int arg1){
      if (arg1 ==1)
         continue;
         //error: continue only allowed in loops. Remove 'continue;'.
   }
}


Compiler Error J0096

Class value expected

The compiler detected a synchronization block, but the synchronized statement was applied to an invalid type. This error usually occurs when an identifier other than a class object instance is used with the synchronized statement.

The following example illustrates this error:

public class Simple {

   public void method1() {
      int i;
      synchronized (i){ //error 'i' must resolve to an object reference
         // Do something here
      }
   }
}


Compiler Error J0097

'instanceof' operator expected class or array

The compiler detected the instanceof operator applied to a type that did not resolve to a class or array. The instanceof operator is used to determine if identifier is an instance of a specific class or array. Ensure the lvalue used with the instanceof operator references a class instance or array and the rvalue references a valid class name or array and compile again.

The following example illustrates this error:

public class Simple {

   public void method1() {

      Simple2 obj = new Simple2();

      if (obj instanceof int) // error: 'int' is not a class name
          // do something meaningful
   }
}

class Simple2 {
   // do something meaningful
}


Compiler Error J0098

Attempt to access non-existent member of 'identifier'

The compiler detected an array member specified, but could not identify it. This error usually occurs when an attempt to reference the length method of an array is mistyped. This error can also occur when an attempt is made to call a method in an array of objects but the call does not reference an element of the array.

The following example illustrates this error:

public class Simple {

   public void method1() {
      String j[] = new String[10];
      //intialize the array elements here
      String str = j.toUpperCase();
      //error: missing array brackets '[]'
   }
}


Compiler Error J0100

Cannot throw 'identifier' — the type does not inherit from 'Throwable'

The compiler detected an object in a throw statement that was not derived from the class Throwable. This error usually occurs when a throw statement uses a class that does not inherit from the Throwable class. Ensure that the exception class you are throwing is a valid exception class.

The following example illustrates this error:

class BogusException{
   //Do something useful here
}

public class Simple{

   public void method1(int arg1){
       //Do something meaningful
       if (arg1 == 0){
          throw new BogusException();
          //error: BogusException is not a valid exception class
       }
   }
}


Compiler Error J0101

The type 'identifier' does not inherit from 'Throwable'

The compiler detected an invalid class argument used as an argument in a catch statement. When using a catch statement to handle exceptions, you must define it with a class derived from Throwable as a parameter. Ensure that the class you defined for the catch statement is derived from Throwable and compile again.

The following example illustrates this error:

public class Simple {

   public void method1() {

      try {
         // do something meaningful
      } catch (String s) {
         // error: 'String' not a subclass
         // of 'Throwable'
      }
   }
}

The following example illustrates the correct way to use the catch statement to trap exceptions:

public class Simple{
   public void method1(int arg1){
      try{
        //do something here
        if (arg1 == 0)
           throw new myException(); //throw a valid exception object
      }
      catch(myException c){ //this is a valid exception object to catch
         //handle exception here
      }
   }
}
class myException extends Throwable{
   //class definition goes here
}


Compiler Error J0102

Handler for 'identifier' hidden by earlier handler for 'identifier'

The compiler detected an exception handler that will never be executed because an earlier handler would have already caught the exception. This error usually occurs when catch statements are written in the wrong order.

The following example illustrates this error:

class Simple {

   static
   {
      try
      {
      }
      catch (Exception e)
      {
      }
      catch (ArithmeticException e)
      {
      }
      // error: any exceptions this block
      // could have caught are already caught
      // by the first catch statement
   }
}


Compiler Error J0103

Cannot override final method 'identifier'

The compiler detected a class method attempting to override one of its base class methods, but the base class method was declared with the keyword final. Methods defined with the final modifier cannot be overridden by a derived class.

The following example illustrates this error:

public class Simple extends Simple2 {

   public void method1() {
      // error: ‘method1’ final in superclass
   }
}

class Simple2 {

   public final void method1() {
      // do something meaningful
   }
}


Compiler Error J0104

Unreachable statement or declaration

The compiler detected a statement or declaration that cannot be reached under any circumstances. This error usually occurs when a return statement is called from a method, and code is placed below the return statement. This error can also occur if a break statement is used in a loop without any flow control to allow code below it to be run.

The following example illustrates this error:

class Simple {
   public int method1(int arg1){
      for (int y = 10; y < 10;y++){
         break;
         int z = y +10; //error: break causes this line to never be run
      }
      //do something here
      return arg1;
      int x = arg1 /2;
      /*error: this line of code cannot be reached because of return
               statement */
   }
}


Compiler Error J0105

Method 'identifier' must return a value

The compiler detected a method declaration that included a return type other than void, but the keyword return was not found in the method body. This error usually occurs when a method that returns a value is missing a valid return statement. This error can also occur if a return statement is called within a flow control block and cannot always be accessed due to the logic of the method.

The following example illustrates this error:

public class Simple {

   public int method1(int arg1) {
      if (arg1==0)
         return arg1 + 2;
   } // error: flow control prohibits a value from always being returned
}


Compiler Error J0106

Class 'identifier' has a circular dependency

The compiler detected two or more classes directly or indirectly attempting to subclass each other. This error usually occurs when two classes extend each other. One class should act as the base class of the other.

The following example illustrates this error:

public class Simple extends Simple2 {

   // error: extending ‘Simple2’
}

class Simple2 extends Simple {

   // error: also extending ‘Simple’
}


Compiler Error J0107

Missing array dimension

The compiler detected the initialization of an array, but failed to detect a valid array dimension. This error usually occurs when an array is defined but one of the dimensions of the array is not defined. In order to use an array, all dimensions must be defined.

The following example illustrates this error:

public class Simple {

   public void method1() {

      int [][] i = new int[][12];
      // error: missing first array dimension
   }
}


Compiler Error J0108

Cannot 'new' an instance of type 'identifier'

The compiler detected an attempt to instantiate a data type that does not require the use of the keyword new. This error usually occurs when an attempt is made to use the new keyword with an intrinsic data type and the declaration is not an array. Ensure your member declaration does not use the new keyword unless it is a class object or array declaration.

The following example illustrates this error:

public class Simple {

   public void method1() {
      String myString = new String(); /*usage OK since it is a class
                                        object*/
      int x[] = new int[10]; //usage of new here is OK
      int i = new int(5);
      // error: cannot use 'new' on 'int' types
   }
}


Compiler Error J0109

Cannot 'new' an instance of abstract class 'identifier'

The compiler detected an attempt to instantiate a class object declared as abstract. A class declared as abstract cannot be instantiated and exists only as a base class for other classes to derive from.

The following example illustrates this error:

abstract class Simple2 {
   // do something meaningful
}

public class Simple {

   public void method1() {

      Simple2 s2Object = new Simple2();
      // error: class ‘Simple2’ declared as abstract
   }
}


Compiler Error J0110

Cannot 'new' an interface 'identifier'

The compiler detected an attempt to instantiate an interface object declared as abstract. Interfaces can only be implemented by a class, and thus cannot be instantiated in the way a class can.

Note Interfaces are abstract by default, regardless of whether or not the keyword abstract is used in their declaration.

The following example illustrates this error:

interface Simple2 {
   // do something meaningful
}

public class Simple {

   public void method1() {

      Simple2 s2Object = new Simple2();
      // error: interface Simple2 is abstract
   }
}


Compiler Error J0111

Invalid use of array initializer

The compiler detected an attempt to initialize an array, but the initialization statement was not syntactically correct. Arrays can be initialized at declaration with an initial set of values. This error usually occurs when trying to initialize an array of arrays with the incorrect number or positioning of braces and commas. Ensure that the syntax of your array initialization is correct and compile again.

The following example illustrates this error:

public class Simple{
   public void method1(){
      int[]i = {{1,2,3}, {4,5,6}};
      //error: 'i' delcared for only one dimension
   }
}

The following example illustrates the proper syntax for array initialization:

public class Simple{
   public void method1(){
      int[]i = (1,2,3,4,5,6}; //single dimension initialization
      int [][]x = {{1,2,3},{4,5,6}};//multi-dimension initialization
   }
}


Compiler Error J0112

Cannot assign final variable 'identifier'

The compiler detected an attempt to change the value of a field declared as final. A field declared as final cannot be assigned a value once it has been initialized with a value either at declaration, in an instance initializer, or constructor.

The following example illustrates this error:

public class Simple {
   private final int i = 3;

   public void method1(int arg1) {
      i = arg1;
      // error: variable 'i' declared final
   }
}


Compiler Error J0113

Call to constructor must be first statement in constructor

The compiler detected a constructor called from within the body of a second constructor, but the constructor call was not placed at the beginning of the second constructor body. In a constructor, calls to another constructor must be the first line of code in the constructor's body. Ensure that the constructor call is the first line of code in the constructor body and compile again.

The following example illustrates this error:

public class Simple {

   int i, j;
   Simple () {

      i = 0;
   }

   Simple(int arg1) {

      j = arg1;
      this(); // error: call to Simple() must be first
   }
}


Compiler Error J0114

Cannot reference 'this' in constructor call

The compiler detected an improper reference to this in a constructor. The this statement is usually used in a constructor to access methods and fields of the constructor's class. Usage of this(this) or super(this) in a constructor will cause this error to occur because the instance of the class has not yet been created and thus cannot be passed to another constructor.

The following example illustrates this error:

class SuperSimple {
   SuperSimple(){}
   SuperSimple(Object o) { }
}

public class Simple extends SuperSimple {
   int x;
   public Simple()
   {
      this(10); //this is OK; calls another constructor
      super(this);
      //error: cannot pass this to a super constructor
      this.x = 1; //this is OK
      this.method1(); //this is OK too
   }
   public Simple(int arg1){
      this.x = arg1; //this is OK
   }
   public void method1(){}
}


Compiler Error J0115

Cannot call constructor recursively (directly or indirectly)

The compiler detected a recursive constructor call. This error usually occurs when a constructor has a call to the same constructor. This error can also occur if one constructor calls a second constructor and the second constructor has a call back to the first constructor.

The following example illustrates this error:

public class Simple {

   Simple (int arg1) {

      this(1);
      // error: constructor calling itself
   }
}


Compiler Error J0116

Variable 'identifier' may be used before initialization

The compiler detected an attempt to use a variable before it was properly initialized. In order to use a variable in an assignment or expression, you need to assign it a value. Initialize the variable in a constructor or field initializer and compile again.

The following example illustrates this error:

public class Simple {

   static
   {
      int i;
      int j = i;
      // error: 'i' not yet initialized

   }
}


Compiler Error J0117

Cannot declare an interface or outer class to be 'private'

The compiler detected use of the modifier private in an outer class or interface declaration. This modifier may only be used with fields, methods, and inner class declarations.

The following example illustrates this error:

private class Simple {

   // error: a class cannot be 'private'

}


Compiler Error J0120

Divide or mod by zero

The compiler detected a division by zero error.

The following example illustrates this error:

public class Simple {

   final int x = 0;
   int y = 1 % x;
   //error: x cannot be 0

}


Compiler Error J0121

Unable to recover from previous error(s)

The compiler encountered a serious error and could not continue processing the file reliably. Fix whatever errors are already flagged and compile again.


Compiler Error J0122

Exception 'identifier' not caught or declared by 'identifier'

The compiler detected an exception that was thrown but never caught within the exception class. This error usually occurs when a method calls another method that is declared to throw an exception. In order for a method to call another method that throws an exception, the method must either be declared to throw the exception or handle the error using a try/catch combination.

The following example illustrates this error:

class SimpleException extends Exception {
   // do something meaningful
}

class Simple {

   void method1() throws SimpleException { }
   void method2() { method1(); }
   // error: exception not declared for method2
}

The following examples illustrates how to call a method that is declared to throw an exception:

/*This example illustrates handling by declaring the other method as
throwing an exception duplicate to the method it is calling.*/
class SimpleException extends Exception{
   //do something here
}

public class Simple{
   void method1() throws SimpleException{
      //do something here
   }
   void method2() throws SimpleException{
      method1(); //caller of method2 now is forced to handle exception
   }
}

/*This example illustrates handling the exception using a try/catch
  combination.*/
class SimpleException extends Exception{
   //do something here
}

public class Simple{
   void method1() throws SimpleException{
      //do something here
   }
   void method2(){
      try{
        method1();
      }
      catch(SimpleException e){
         //handle exception here
      }
   }
}


Compiler Error J0123

Multiple inheritance of classes is not supported

The compiler detected a class attempting to apply the keyword extends to more than one base class. This is defined as multiple inheritance in other languages and is not supported in Java.

The following example illustrates this error:

public class Simple extends BaseClass1, BaseClass2 {
   // error: multiple inheritance not supported in Java
}

class BaseClass1 {

   // do something meaningful
}

class BaseClass2 {

   // do something meaningful
}


Compiler Error J0124

Operator cannot be applied to 'identifier' values

The compiler detected an operator being applied to a type it cannot be used with. Ensure that the operator you are attempting to use is valid for that type of variable or object and compile again.

The following example illustrates this error:

public class Simple {

   void method1(boolean b) {

      b++;
      /* error: post increment operator cannot
         be applied to boolean variables */
   }
}


Compiler Error J0125

'finally' block used without 'try' statement

The compiler detected a finally block but did not find a corresponding try statement. A finally block is used to execute code after a try statement, regardless of the results of the try statement.

The following example illustrates this error:

public class Simple {

   public void method1() {

      finally {
         // error: missing corresponding try statement
      }
   }
}

The following example illustrates the correct usage of the finally block:

public class Simple{

   public int method1(int arg1){
      try{
         arg1/10;
      }
      catch(Exception e){
         //handle exception here; must come before 'finally'
      }
      finally{
        //do something here; this section is run regardless of 'try'
      }
   }
}


Compiler Error J0126

'catch' block used without 'try' statement

The compiler detected a catch statement but did not find a corresponding try statement. In order to use a catch statement you must have a try statement preceding it. Ensure that you have a valid try statement preceding your catch statement and compile again.

The following example illustrates this error:

public class Simple {

   public void method1() {

      catch {
         // error: missing corresponding try statement
      }
   }
}

The following example illustrates the proper usage of the catch block:

public class Simple {

   public void method1() {
      try{
         //do something here
      }
      catch (Exception e){
         //handle exceptions from try statement here
      }
   }
}


Compiler Error J0127

'else' keyword used without 'if' statement

The compiler detected the keyword else but did not find a corresponding if statement. This error usually occurs when there are scoping issues regarding the placement of an else statement. It can also occur if an else statement's corresponding if statement is missing.

The following example illustrates this error:

public class Simple {

   public void method1(int arg1) {
      if (arg1 == 0){
        //Do something here
        else{}
           //error 'else' is inside of the 'if' block instead of outside
      }
   }
}


Compiler Error J0128

Cannot declare an interface to be 'final'

The compiler detected an interface declared with the keyword final. Interfaces cannot be defined as final and thus cannot use the final modifier. Remove the final keyword from the interface declaration and compile again.

The following example illustrates this error:

final interface Simple {

   /*error: 'final' only applies to
      classes, methods,or variables*/

}


Compiler Error J0129

Cannot declare a class to be 'identifier' and 'identifier'

The compiler detected a class declared with modifiers that cannot be combined. Ensure that the modifiers you have applied to the class do not conflict with each other and compile again.

The following example illustrates this error:

public abstract final class Simple {

   /*error: 'abstract' and 'final' cannot
     be used together in a class declaration*/

}


Compiler Error J0130

Cannot declare an interface method to be 'native', 'static', 'synchronized' or 'final'

The compiler detected one of the keywords shown in the error message used in the declaration of an interface method. Because an interface method does not have implementation code, it cannot be declared as native, static, synchronized, or final.

The following example illustrates this error:

interface Simple {

   public final void method1();
   /*error: ‘method1’ cannot be declared
      as final in an interface*/
}


Compiler Error J0131

Cannot declare a method to be 'identifier' and 'identifier'

The compiler detected the use of two or more incompatible modifiers in the declaration of a method. This error usually occurs when a method has been defined with two access modifiers such as public and private. Ensure that the modifiers for the method do not conflict with each other and compile again.

The following example illustrates this error:

public class Simple {

   public private void method1() {

      // error: modifiers 'public' and 'private'
      // cannot be combined in a declaration
   }
}


Compiler Error J0132

Cannot declare a field to be 'identifier' and 'identifier'

The compiler detected the use of two or more incompatible modifiers in the declaration of a variable. This error usually occurs when a field has been defined with two access modifiers such as public and private. Ensure that the modifiers for the field do not conflict with each other and compile again.

The following example illustrates this error:

public class Simple {

   public private int i;
   // error: modifiers 'public' and 'private'
   // cannot be combined in a declaration
}


Compiler Error J0133

Constructors cannot be declared 'native', 'abstract', 'static', 'synchronized', or 'final'

The compiler detected the use of one of the modifiers shown above in the declaration of a constructor. Ensure that the constructor is not defined with any of the modifiers mentioned in the error message and compile again.

The following example illustrates this error:

public class Simple {

   final Simple() {}
   // error: constructors cannot be 'final'

}


Compiler Error J0134

Interfaces cannot have constructors

The compiler detected an interface containing a constructor declaration. Because an interface cannot be instantiated, constructors cannot be defined for an interface. If you are defining a method with the same name as the interface, ensure that it has the appropriate modifiers to differentiate it from a constructor declaration.

The following example illustrates this error:

interface Simple {

   Simple();
   // error: interfaces cannot
   // declare constructors

}


Compiler Error J0135

Interface data members cannot be declared 'transient', 'volatile', 'private', or 'protected'

The compiler detected one of the modifiers shown above used in the declaration of an interface member variable. Because interfaces are public and cannot be instantiated, these modifiers are not applicable and should be used with classes only.

The following example illustrates this error:

interface Simple {

   volatile int i = 1;
   // error: 'volatile'cannot be used

}


Compiler Error J0136

Public class 'identifier' should not be defined in 'identifier'

The compiler detected more than one class declared with the modifier public in a source file. Remove the public access modifier from other classes and ensure that the class that will be exposed through the class file is declared as public. You can also move classes that need to remain declared as public to their own source file. This error can also occur if a source file has a different name than the public class defined within it, or the public class and the source file do not match in case. Rename the source file or the name of the public class defined within it so that they are the same and compile again.

The following example illustrates this error:

public class Simple {

   // do something meaningful

}

public class Errorclass {

   // error: only one class may be defined as
   // 'public' within the same source file

}


Compiler Error J0138

Interface cannot have static or instance initializer

The compiler detected a static initializer or instance initializer within an interface. Because an interface does not get instantiated, initializers cannot be defined in an interface. To set the values of interface fields, initialize them at the time of declaration.

The following example illustrates this error:

interface Simple {
   int x = 10; //This is OK
   {
      // error: initializers cannot
      // be used in interfaces
   }
}


Compiler Error J0139

Invalid label

The compiler detected an invalid label. Labels must start with a non-numeric character. Change the label and compile again.

The following example illustrates this error:

public class Simple {

   public int method1(int arg1) {
      123:
         //error: label cannot begin with a number.
         return arg1 * 2;
   }
}


Compiler Error J0140

Cannot override static method 'identifier' with non-static method ‘identifier’

The compiler detected an attempt to override a static method from within a subclass. A method that has been declared as static cannot be overridden.

The following example illustrates this error:

public class Simple {

   static void method1() {}
}

class SimpleSubclass extends Simple {

   void method1() {}
   // error: cannot override
   // static method
}


Compiler Error J0141

Argument cannot have type 'void'

The compiler detected a method argument defined as type void. The void type can only be used for method return values to declare a method has no return value. Change the data type of the argument and compile again.

The following example illustrates this error:

public class Simple {

   public void method1(void i) {
      // error: type void can only
      // be used as a return value
   }
}


Compiler Error J0142

Cannot make static call to abstract method 'identifier'

The compiler detected an attempt to directly call an abstract method. Abstract methods are defined to provide a definition of a method to be implemented by subclasses; therefore, abstract methods do not have implementation code. Because of this lack of implementation in an abstract method, calling an abstract method using the super keyword is invalid.

The following example illustrates this error:

public abstract class Simple {

   abstract int method1();
}

class SimpleSubclass extends Simple {

   int method1() {

      return super.method1();
      // error: cannot call abstract method
   }
}


Compiler Error J0143

Cannot throw exception 'identifier' from static initializer

The compiler detected an attempt to throw an exception from within a static initializer. This error usually occurs when a throw statement is called or when an initialization of a static class instance occurs within a static initializer. To capture exceptions from static class instance intializations in a static initializer, use a try/catch block combination.

The following example illustrates this error:

public class Simple {

   static {
      ThrowClass TClass = new ThrowClass();
      // error: cannot throw exceptions
      // within static initializers
   }
}

class ThrowClass {

   ThrowClass() throws Exception{}

}

The following example illustrates how to use the try/catch block combination to capture potential errors when initializing static class instances in a static initializer:

public class Simple{
   static ThrowClass thr;
   static{
     try{
        ThrowClass thr = new ThrowClass();
     }
     catch (Exception e){
         //Handle errors here from initialization of 'ThrowClass'
     }
   }
}

class ThrowClass {
   ThrowClass() throws Exception(){
      // Do something here
   }
}


Compiler Error J0144

Cannot find definition for interface 'identifier'

The compiler could not locate a definition for the named interface. This error usually occurs when an implemented interface is either missing or misspelled. Verify the location and name of the interface you are implementing and compile again.

The following example illustrates this error:

public class Simple implements Bogus {
   // error: the interface 'Bogus' does not exist

}


Compiler Error J0145

Output directory or file too long: 'identifier'

The output directory or source file being saved exceeds 228 characters in length. Shorten the length of the output directory path or source file and compile again.


Compiler Error J0146

Cannot create output directory 'identifier'

The output directory could not be created. This error usually occurs when you do not have write permission on the specified drive.


Compiler Error J0147

Cannot access private member 'identifier' in class 'identifier' from class 'identifier'

The compiler detected an invalid attempt to access a private member contained within another class. Private class members are only accessible from within the member's class. A class’s private members are also available from its inner classes.

The following example illustrates this error:

class AccessClass {

   private int i = 0;

}

public class Simple {

   public void method1() {

      AccessClass ac = new AccessClass();

      ac.i = 1;
      // error: cannot access 'i'
   }
}


Compiler Error J0148

Cannot reference instance method 'identifier' before superclass constructor has been called

The compiler detected an attempt to reference an instance method before the superclass constructor was called. This error usually occurs when a base class method is called from within a subclass's constructor using the super() statement. This error can also occur if the subclass calls its own methods from the constructor using the this() statement. This error occurs because instances of the subclass and base class have not been instantiated at the time the constructor is called. To avoid this situation, use the super. statement to call a base class method, and use the this. statement to call a subclass method.

The following example illustrates this error:

abstract class Simple {

   Simple(int i) {}

   int method1() {

      return 0;
   }
}

class SimpleSubclass extends Simple {

   SimpleSubclass() {

      super(method1());
      // error: constructor must be called first
   }
}

Using the abstract class from the example above, the following example illustrates how to call the base class method from the constructor:

class SimpleSubclass extends Simple{

   SimpleSubclass(){
     super.method1();
   }
}


Compiler Error J0150

Cannot have repeated interface 'identifier'

The compiler detected an interface name being repeated within a class declaration. This error is usually caused when a class implements a large number of interfaces and one of the interfaces has a duplicate entry in the implements list. Ensure that you do not have a duplicate interface entry and compile again.

The following example illustrates this error:

interface SimpleI {
   // do something meaningful
}

class Simple implements SimpleI,IColor,IFont, SimpleI {
// error: 'SimpleI' repeated
}


Compiler Error J0151

Variable 'identifier' is already defined in this method

The compiler detected two variables with the same name that are defined twice within the same scope of a method. Ensure that a variable has not been defined twice in the same scope or that a variable has not been defined the same name as an argument passed to the method and compile again.

The following example illustrates this error:

public class Simple {

   public void method1() {

      int i = 1;
      int j = i;
      //more code here
      int i = 0;
      // error: 'i' defined twice within
      // the same scope

   }
}


Compiler Error J0152

Ambiguous reference to 'identifier' in interfaces 'identifier' and 'identifier'

The compiler detected an ambiguous reference to an identifier. The identifier may have been declared in two or more interfaces, and the compiler could not determine which reference to use. Ensure that you do not have two interfaces with the same field defined.

The following example illustrates this error:

interface Interface1 {
    final int i = 0;
}

interface Interface2 {
    final int i = 1;
}

public class Simple implements Interface1, Interface2 {

   int method1() {
      return i; //error: cannot determine which instance of 'i' to use
   }
}


Compiler Error J0158

Class 'identifier' already defined

The compiler detected two or more classes defined with the same name. Ensure that you do not have the class defined more than once (as an outer class) in the same source file or package. This error can also occur if a class is duplicated by an imported class. Rename one of the classes or remove the duplicate instance and compile again.

The following example illustrates this error:

public class Simple {
   // do something meaningful
}

class Simple {
   // error: class 'Simple' already defined
}


Compiler Error J0159

'@' must be followed by the response filename

The compiler detected the @ character on the JVC command line, but did not detect a valid response filename immediately following it. Supply the response filename and compile again.


Compiler Error J0160

Response file 'identifier' could not be opened

The compiler could not open the specified response file. This error usually occurs when the response file name is misspelled or the file does not exist. Check the location of the response file and compile again.


Compiler Error J0161

Cannot open source file: 'identifier'

The source file specified in the error message could not be opened. This error usually occurs when either the filename specified is misspelled or the file does not exist. Check the location of the specified source file and compile again.


Compiler Error J0162

Failed to initialize compiler

The compiler failed to properly initialize. This error most often occurs because the compiler and/or the Microsoft Virtual Machine for Java (VM) are not properly installed or are the incorrect version. Confirm the correct version and installation of the VM and compiler.


Compiler Error J0163

Array 'identifier' missing array index

The compiler detected access to an array type, but the index value was missing. To access an element of an array, you must provide a valid integer index for the array. Ensure that a valid integer is used to reference an index of the array and compile again.

The following example illustrates this error:

public class Simple {

   int j[] = {1, 2, 3};

   void method1() {
      j[] = 0;
      // error: 'j' missing index value
   }
}


Compiler Error J0164

Ambiguous import of class 'identifier' from more than one package

The compiler detected two or more import statements attempting to import identical class names from different packages. This error usually occurs when two packages contain duplicate classes and both packages are imported into the same source file. Check the packages imported into the source file for duplicate classes. Remove the duplicate class from one of the packages or remove one of the import statements from the source file.

The following example illustrates this error:

import Box.Test; //This package contains a class named 'Test'
import Carton.Test; //This package contains a class named 'Test' also
//error: which 'Test' class should be used by the compiler?

public class Simple{
   //Do something here
}


Compiler Error J0165

Cannot throw exception 'identifier' from method 'identifier' -- it is not a subclass of any exceptions thrown from overridden method 'identifier'

The compiler detected an overridden method attempting to throw more exceptions than the method it overrides. In Java, an override method cannot be declared to throw more exceptions than the overridden method. Either change the exception thrown to one that the base class throws, or change the base class declaration to throw the exception type that the subclass needs to throw.

The following example illustrates this error:

class ExceptionA extends Exception {
   // do something meaningful
}

class ExceptionB extends Exception {
   // do something meaningful
}

class AnotherClass {

   public void method1() throws ExceptionA {
      // do something meaningful
   }
}

public class Simple extends AnotherClass {

   public void method1() throws ExceptionA, ExceptionB {
      // error: cannot throw greater than
      // one exception here
   }
}


Compiler Error J0166

Cannot access member 'identifier' in class 'identifier' from 'identifier' -- it is in a different package

The compiler detected an invalid attempt to reference a member variable or method defined within a different package. This error usually occurs when an attempt is made to access a protected or default access member defined within another package. Protected or default access members of a class located in a different package are not accessible. Ensure that the member you are attempting to access in another package is not a protected or default access member.


Compiler Error J0167

Cannot override non-static method 'identifier' with static method 'identifier'

The compiler detected an attempt to override a superclass method with a subclass method declared with the modifier static. When a method is overridden in a subclass, the method cannot raise or lower the access level of the method or apply the static modifier. Remove the static modifier from the overridden method declaration and compile again.

The following example illustrates this error:

public class Simple {

   public void method1() {
      // do something meaningful
   }
}

class Simple2 extends Simple {

   static public void method1() {
      // error: overriding superclass 'method1'
      // with a static method is not valid
   }
}


Compiler Error J0168

The declaration of an abstract method must appear within an abstract class

The compiler detected a method declared with the modifier abstract within a class which was not defined as abstract. This error usually occurs when a class is intended to be abstract but is missing the abstract modifier in the class declaration. Either change the class so it is declared as abstract or remove the modifier from the methods defined in the class.

The following example illustrates this error:

public class Simple {

   abstract void method1();
      // error: class must also be abstract
}


Compiler Error J0169

Cannot access 'identifier' -- only public classes and interfaces in other packages can be accessed

The compiler detected an attempt to access a non-public class or interface contained within another package. Only classes or interfaces defined with the modifier public can be accessed in other packages. Check the access level of the class or interface you are accessing in the other package to ensure that it is public and compile again.

The following example illustrates this error:

//Source located in 'Boxes.Java' in the 'Box' package
package Box;
public class Box{
   TapeRoll tr = new TapeRoll();
   //Do meaningful stuff here
}
class TapeRoll{
   //Define the class here
}

//Source located in 'Simple.java'
import Box.TapeRoll;
public class Simple{
   public static void main(String args[]){
      Box.TapeRoll tr = new Box.TapeRoll();
      //error: cannot access a 'non-public' class in a different package
   }
}


Compiler Error J0170

Cannot load predefined class 'identifier'

The compiler attempted to load a predefined class, but was unable to find the appropriate file. This error usually occurs when the Java API class files cannot be found on the system or the correct version of the Microsoft Virtual Machine for Java (VM) is not properly installed. Ensure that your Java API class files and the VM have been installed properly on the system and compile again.


Compiler Error J0173

Found class 'identifier' in package 'identifier' rather than package 'identifier'

The compiler found the specified class, but the class was not defined as a member of the correct package. This error usually occurs when the class file is being imported from the wrong directory. Ensure that the class you are importing is located in the correct package directory and compile again.


Compiler Error J0175

Cannot invoke method on 'null' literal

The compiler detected an attempt to call a method from the null keyword. Null is not a class object and provides no methods. Remove the statement that attempted a method call from the null keyword and compile again.

The following example demonstrates this error:

public class Simple{
   public String methdo1(){
      //Do something meaningful here
      return null.toString();
      //error : cannot invoke a method from 'null'
   }
}


Compiler Error J0176

Duplicate label 'identifier' nested inside another label with same name

The compiler detected a nested label that was the same as another label. Rename the label to something different. Change all break and continue statements that reference the label and compile again.

The following example illustrates this error:

public class Simple{
   void method1(){
      outsideLoop:
      for (int i=0;i<10;i++)
      {
         outsideLoop:  //error: duplicate label
         for (int x=0;x<10;x++)
         {
            break outsideLoop;
         }
         break outsideLoop;
      }
   }
}


Compiler Error J0189

'return' not allowed in a static initializer or instance initializer

A return statement was found in a static or instance initializer. Initializers, like constructors, can not return a value. Remove the return statement and compile again.

The following example illustrates this error:

public class Simple{

   static int var1;

   static{
      var1 = 0;
      return;
      //error: return statement not allowed in static initializer
   }
}


Compiler Error J0191

Expected '.class'

The compiler detected usage of an intrinsic type name in an expression or assignment statement but did not find .class after the name. This error usually occurs when the .class keyword is omitted. Add the .class extension to the end of the intrinsic type and compile again.

The following example illustrates this error:

public class Simple{
   public static void main (String args[]){
      Class x = int;//error: missing '.class'
   }
}


Compiler Error J0192

'.class' on intrinsic type requires Java 1.1 compatible class libraries

The compiler detected usage of the .class keyword with an intrinsic data type, but either the Microsoft Virtual Machine (VM) for Java or the Java class libraries are based on Java 1.0. Ensure that your class libraries and Java VM are the Java 1.1 versions and compile again.


Compiler Error J0193

Cannot have an array of type 'void'

An attempt to define an array of type void was found by the compiler. The void data type is for use with methods to declare that the method has no return value and can not be used as an array.

public class Simple{

   void MyArray[]; //error: void arrays not supported

}


Compiler Error J0194

Class or interface cannot be declared 'volatile', 'native', 'transient', or 'synchronized'

The compiler detected that an inner class or interface was declared with one of the above mentioned modifiers. This error usually occurs when a method or field modifier is applied to an inner class or interface definition. Inner classes and interfaces can use the private, public, and protected access modifiers. Inner classes can also use modifiers such as abstract, static, and final.

The following example illustrates this error:

public class Simple{
   //Do something here
   volatile class InnerClass{
      /*error: like outer class, inner classes cannot be defined as
               volatile */
   }
}


Compiler Error J0195

Cannot declare 'identifier' as 'static' in inner class 'identifier'

The compiler detected an attempt to declare a variable or method as static from within an inner class. Unlike regular class declarations, inner classes do not support static members. Classes defined within another class, that are declared as static, can have static members but the class is considered an outer class. This error can also occur if an interface was defined within an inner class.

The following example illustrates this error:

public class Simple{

   //Do something meaningful here

   class InnerClass{

   static int var1; /* error: cannot declare static
                              members in inner class*/
   }
}

The following example illustrates how to define a class within a class that can contain static members:

public class Simple{

   //Do something meaningful here

   /*Because 'InnerClass' class is declared as static it is now treated
     as an outer class enclosed within the 'Simple' class*/
   static class InnerClass{
      static int var1 = 100; // This is OK as long as the class is static
   }
}


Compiler Error J0196

Nested class 'identifier' cannot have the same name as any of its enclosing classes

The specified inner class has the same name as one of the classes that it is nested under. Ensure that you have not duplicated the name of a class in which your inner class is nested within and compile again.

The following example illustrates this error:

public class Simple{

   // Do something meaningful here
   class InnerClass{
      //Do something meaningful here
        class Simple{
            //error: inner class has same name as a parent class
        }
   }
}


Compiler Error J0197

Cannot declare interface in inner class 'identifier'

The compiler detected an attempt to declare an interface inside an inner class. Inner class definitions do not support interfaces declared within them. Remove the interface declaration from within the inner class declaration and compile again.

The following example illustrates this error:

public class Simple{
   //Do something meaningful here
   class InnerClass{
   //Do something meaninful here
      interface MyInterface{
         /*error: interfaces cannot be declared
                  inside inner classes */
      }
   }
}


Compiler Error J0198

An enclosing instance of type 'identifier' is required

The compiler detected that an inner class definition tried to reference something outside of its scope. Examples of when this can occur are:

  • A class declared within another class as static referenced one of the parent class's non-static variables or methods. Since the inner class is declared static it cannot reference any members of the parent class without an instance of the parent class defined.

  • An inner class tried to reference a class that was not its outer class using the this keyword with the classes name preceding it. Since the referenced class is not the inner class's parent class, an instance cannot be implied.

The following examples illustrate this error:

//This example illustrates the first error situation
public class Simple{
   int x = 10;
   static class InnerClass{
      public void method1(){
         int y = x; /*error: instance variable needed
                             to reference parent
                             variables. */
      }
   }
}

//This example illustrates the second error situation
class A{
   int x;
}
class B{
   //Do something meaningful here
   class InnerClass{
      void method1(){
         int y = A.this.x;
         /*error: no instance of A defined. Cannot use
           the <classname.this.variable> syntax here.*/
      }
   }
}


Compiler Error J0199

Call of 'this()' cannot be qualified

The compiler detected that an inner class's constructor attempted to call it’s outer class constructor using the class name with the this() method. Inner classes cannot call their outer class's constructors. Remove the call to the outer class constructor from the inner class constructor and compile again.

The following example illustrates this error:

public class Simple{
   int x;
   Simple(int x){
      this.x = x;
   }
   class InnerClass{
      InnerClass(){
         Simple.this(10);
         //error: cannot call outer class constructor
      }
   }
}


Compiler Error J0200

'this' must be qualified with a class name

The compiler detected that an attempt was made in an inner class to reference an outer class member using the this keyword with a name other than an outer class's name. Only the name of the outer class can be used from an inner class to reference members of the outer class.

The following example illustrates this error:

public class Simple{
   int x;
   class InnerClass{
      void method1(){
         int j = x.this;
         /*error: only a class name can be used with
         this to reference outer class */
      }
   }
}

The following example illustrates the proper way to reference an outer class's members:

public class Simple{
   int x;
   int method2(int arg1){
     return arg1 * ;
   }
   class InnerClass{
      void method1(){
         int j = Simple.this.x; //This is OK!
         int z = Simple.this.method2(10);
      }
   }
}


Compiler Error J0201

'super' cannot be qualified except as a superclass constructor call

The compiler detected the usage of the super keyword with an instance of the superclass preceding it to access a field or method of the superclass. Using an instance of a superclass, along with the keyword super, is limited to referencing a superclass constructor when the superclass has inner classes defined within it.

The following example illustrates this error:

class Simple{
   int x;
}

class NotSimple extends Simple{
   NotSimple(Simple smp){
      smp.super.x = 100;
      /*error Cannot reference field with superclass
              name */
      super.x = 100;//This is OK!
   }
}


Compiler Error J0202

'super()' cannot be qualified; superclass 'identifier' is not an inner class

The compiler detected a call to a superclass constructor using an instance of the superclass but the superclass is not an inner class. The usage of an instance of a superclass combined with the super keyword is only used when a superclass is an inner class.

The following example illustrates this error:

class Simple{
   //Do something meaningful here
}

class NotSimple extends Simple
{
   NotSimple(Simple smp){
      smp.super();
      /*error: cannot call 'super' with instance when
        superclass does not contain inner classes*/
   }
}

The following example shows the usage of a superclass instance with the super keyword:

class Simple{
   //Do something here
   class InnerClass{
      int var1, var2;
   }
}

public class NotSimple extends Simple.InnerClass{
   NotSimple(Simple smp){
     smp .super();
     //This is OK!
   }
}


Compiler Error J0203

Cannot access protected member 'identifier' in class 'identifier' from class 'identifier'

The compiler detected an attempt to access a protected member from a class in a different package. A protected member of a class may be accessed from outside the package in which it is declared only by code that is responsible for the implementation of that class. Remove the call to the other package's protected member or make your class a subclass of the other package's class and compile again.

The following example illustrates this error:

/*(source located in a file called PublicClass.java in
   the the Boxes Package directory) */
package Boxes;

public class PublicClass{
   protected void method1(){
      //Do something here
   }
}

//(source located in a file called Simple.java)
import Boxes.PublicClass;

public class Simple extends PublicClass{
   public void method1(){
      PublicClass pub = new PublicClass();
      pub.method1();
      /*error: Cannot access protected method 'method1' because it
               is located in a different package.*/
   }
}


Compiler Error J0204

Cannot access protected member 'identifier' in class 'identifier' via a qualifier of type 'identifier'

The compiler detected that a class in one package, that is extending a class in another package, attempted to access a protected member of the base class using an instance of the base class. This error usually occurs when a class attempts to access members of its base class through an instance other than this, super, or an instance of the derived class. Ensure that the base class's protected member is accessed using the this or super keyword, or an instance of the derived class and compile again.

The following example illustrates this error:

/*(source located in a file called Point.java located in the Boxes package directory) */
package Boxes;

public class Point{
   protected int x, y;
   //Do other meaningful code here
}
//(source located in a file called simple.java)
import Boxes.Point;

public class Simple extends Point{
   public void method1(Point p){
      super.x = 0; //this is OK!
      p.x = 0; /*error: cannot use a protected member
                 for usage other than extending it. */
   }
}


Compiler Error J0205

Cannot use non-final local variable 'identifier' from a different method

The compiler detected that a local variable, which was not declared as final, was referenced in a method. This error can occur if an inner class is defined in a local block or method declaration and the inner class attempts to reference a parameter or local variable defined outside of its scope.

The following example illustrates this error:

public class Simple{
   void method1(int var1){
      class InnerClass{
         boolean getVar1(){
           return(var1 == 1);
           /*error cannot reference local variable of
                   method from within inner class. */
         }
      }
   }
}


Compiler Error J0206

Cannot assign a second value to blank final variable 'identifier'

The compiler detected an attempt to assign a value to a final variable more than once. This error usually occurs when a blank final variable is initialized more than once in a constructor or initializer. Check for duplicate initializations of the final variable mentioned in the error message and compile again.

The following example illustrates this error:

public class Simple{
   final int var1;

   {
      var1 = 10;
      //Do other initializations here
      var1 = 20; //error: duplicate assignment
   }
}


Compiler Error J0207

Cannot assign blank final variable 'identifier' in a loop

The compiler detected that a final variable was assigned a value from within the scope of a program control loop. A final variable can only be assigned a value once and thus cannot be initialized within a loop. Move the initialization of the final variable specified in the error message outside of the loop and ensure that it is initialized only once.

The following example illustrates this error:

public class Simple{
   final int x;

   public Simple(){
      for (int z=0;z<10;z++){
         x = z; /*error: cannot assign final variable
                  in loop */
      }
   }
}


Compiler Error J0208

Constructor or instance initializer must assign a value to blank final variable 'identifier'

The compiler detected that a final variable was declared but never assigned a value in either an initializer or constructor. In order for a variable to be properly declared final it must be assigned a value.

The following example illustrates this error:

public class Simple{
   final int x; //error: final variables must be assigned a value
   final int z = 10; //This is OK
}


Compiler Error J0209

Expected '='

The compiler detected that an equal sign was missing from a comment tag (for example @com, @security, @dll) attribute. This error usually occurs when an equal sign is missing from an attribute in a comment tag declaration. This error can also occur if another symbol or character obscures the equal sign from being evaluated by the compiler. Ensure that all comment tag attributes have proper equal signs applied and compile again.

The following example illustrates this error:

/**@com.interface(iid 31415926-5358-9793-2384-612345678901)*/
//error: missing equal sign in 'iid' parameter
interface Itest{
   //Do something meaningful here
}


Compiler Error J0210

Expected '.'

The compiler detected that the specified comment tag's declaration (for example @com, @dll) is missing a period after the comment tag (for example @com.method). This error can also occur if another symbol or character obscures the period symbol from being evaluated by the compiler. Ensure that your comment tag declaration contains a period after the comment tag and compile again.

The following example illustrates this error:

/**@com class*/
//error: missing '.' from @com statement

public class Simple{
   //Do something meaningful here
}


Compiler Error J0214

Invalid GUID specified

The compiler detected that an @com attribute that requires a GUID has an invalid GUID entry. This can be caused by a syntax error in entering the GUID. Check the syntax for the GUID and compile again.


Compiler Error J0215

Syntax error in @com declaration

A syntax error was found in the specified @com declaration. This is most often caused by incorrectly typing the declaration. Check the syntax of the @com declaration and compile again.

The following example illustrates this error:

/** @com.inteface (iid=31415926-5358-9793-2384-612345678910)
//error:  The word 'interface' is misspelled.
interface ITest{
   //Do something here
}


Compiler Error J0216

@com attribute 'identifier' on 'identifier' is illegal in this context

The compiler has detected that a value assigned to an attribute within an @com declaration is illegal. This error most often occurs when an attribute is specified but usage of the attribute requires that other specific attributes be specified. This error can also occur if an attribute is specified in the wrong location within an @com declaration.


Compiler Error J0217

@com attribute 'identifier' was not specified for 'identifier' but is required in this context

The compiler detected an attribute (for the @com declaration shown in the error) that is missing and that is required for this type of declaration. Each type of @com declaration has attributes that are required. See the documentation on @com for more details on what attributes are required for the @com declaration that is listed in the error message.

The following example illustrates this error:

/**@com.class() */
//error: must specify classid for @com.class
public class Simple{
   //Do something here
}


Compiler Error J0218

@com attribute 'identifier' on 'identifier' has an invalid value

The compiler detected that the value specified in the error message is either not the correct type for the attribute specified in the error or is outside the valid range for the attribute. Check the value assigned to the specified attribute and compile again.

The following example illustrates this error:

/** @com.class(classid=911CAED0-2957-11d1-A55E-00A0C90F26EE) */
class Simple{
   /** @com.parameters([type=CUSTOM, customMarshal="foo.bar",
       customMarshalFlags = 5] i) */
       //error: customMarshalFlags cannot be set higher than 3
   native void method1(Object i);
}


Compiler Error J0219

An @com attribute cannot be placed on member 'identifier' unless the containing class or interface also has an @com attribute

The compiler detected that an @com declaration was placed on a member of a class or interface, but the class or interface was not declared with an @com declaration. Ensure that the class or interface which contains the method specified in the error has a valid @com declaration defined and compile again.

The following example illustrates this error:

interface Simple{
   /**@com.method(dispid=777); */
   public void method1();
   /*error: interface does not have an @com comment tag
            assigned*/
}


Compiler Error J0220

An @com attribute cannot be placed on static member 'identifier'

The compiler detected that an @com declaration was placed on a static member of a class. Static members cannot be exposed through COM. Remove the static keyword from the method or field and compile again.

The following example illustrates this error:

/*@com.class(classid=31415926-5358-9793-2384-612345678910)
public class Simple{
   /**@com.method(dispid=777);*/
   static void method1(){}
   //error: cannot expose static method via COM
}


Compiler Error J0221

The @com attribute on member 'identifier' cannot be used in this type of class or interface

The compiler detected that an @com declaration was placed on a member of a class or method but because of the type of @com attribute used with the class or interface, it is not allowed. This error can occur in the following situations:

  • Using an @com.structmap declaration on a member of a class or interface that has the @com.class or @com.interface declaration applied.

  • Using an @com.method declaration on a member of a class that has the @com.struct declaration applied.

The following example illustrates this error:

/**@com.struct()*/
class Simple{
   /**@com.method(dispid=777)*/
   public native void method1();
   /*error: cannot use @com.method inside of
            @com.struct*/
}


Compiler Error J0222

@com attribute cannot be placed on method 'identifier'-- it must be declared 'native' or be in an interface

The compiler detected that a method was specified with an @com.method or @com.parameters attribute, but the method was not declared with the native modifier or declared in an interface definition. For methods to be exposed through a COM interface they must either be declared in an interface declaration or declared native from within a class declaration.

The following example illustrates this error:

public class Simple{

   /** @com.method(dispid=306); */
   public void method1(){}
   /*error: method must be declared 'native' or
            declared in an interface */
}


Compiler Error J0223

The @com.parameters declaration on member 'identifier' has the wrong number of parameters

The compiler detected that the @com.parameters attribute (specified in the error message) has a different number of parameters than the method it is exposing through COM. Ensure that both the method's declaration and the @com.parameters attribute have the correct number of parameters and compile again.

The following example illustrates this error:

/**@com.interface(iid=31415926-5358-9793-2384-612345678910)*/
interface Itest{
   /** @com.method(dispid=306);
       @com.parameters([type=BOOLEAN] var1, var2, var3)
   */
   public void method1(boolean var1, int var2);
   /*error: extra parameter added to com.parameters
            declaration */
}


Compiler Error J0224

'return' must be the last item in an @com.parameters declaration

When declaring @com.parameters for a method, the return parameter must be the last parameter in the list. The compiler detected the return parameter in a different position within the parameter list. Check the location of the return parameter in the @com.parameters attribute specified in the error message, make the appropriate changes, and compile again.

The following example illustrates this error:

/** @com.class(classid=911CAED0-2957-11d1-A55E-00A0C90F26EE) */
class Simple{
   /** @com.parameters([type=I4] return, [type=CUSTOM,
       customMarshal="foo.bar", customMarshalFlags = 3] i) */
       //error: 'return' cannot be defined as the first parameter
   native int method1(Object i);
}


Compiler Error J0225

An @com.'identifier' declaration is illegal for this type of item

The compiler detected that an @com declaration was defined for the wrong type of item. This error usually occurs as a result of a change to your code, but it is not due to the syntax or placement of an @com declaration. Ensure that the proper @com declaration is used on the specified item in your code.

The following example illustrates this error:

/**@com.interface(iid=31415926-5358-9793-2384-612345678901,dual)*/
interface Itest{
   /**@com.struct()*/
   public int method1();
   //error: wrong type of @com declaration applied
}


Compiler Error J0226

The @com declared type of 'identifier' is illegal for a dispatch or dual interface

The compiler detected that an @com interface declaration, declared as either a dual or dispatch interface, has a member that contains an @com.parameters declaration with an incorrect type. Certain @com.parameters types are not allowed when the interface they are defined in is declared as either a dual or a dispatch interface. The following list shows which values are invalid for type:

  • FIXEDARRAY

  • SYSFIXEDSTRING

  • I8

  • U8

  • STRUCT

  • CUSTOM, CUSTOMBYREF/CUSTOMBYVAL

  • PTR (except PTR to VARIANT)

  • Arrays of any of the above listed values

The following example illustrates this error:

/**@com.interface(iid=31415926-5358-9793-2384-612345678901,dual) */
interface Itest{
   /**@com.parameters([in,out] n , [type = I8] j); */
   /*error: cannot use 'I8' as a type in a dual
            interface */
   public void method1(int n, int j);
}


Compiler Error J0227

It is impossible for an expression of type 'identifier' to be an instance of 'identifier'

The compiler detected that a comparison of two classes using the instanceof operator could never be instances of each other. In order to use the instanceof operator correctly you must compare classes that have some common class lineage. Either change the expression containing the instanceof operator so that it uses a related class and instance for its comparison or remove the expression and compile again.

The following example illustrates this error:

class Simple1{
   //do something meaningful here
}

class Simple2{
   //do something meaningful here
}

class CompClasses{
   Simple1 x = new Simple1();
   public static void main(String args[]){

   if(smp.x instanceof Simple2){
      /*error: non related classes cannot be instances of each other*/
   }
}

The following example illustrates the correct usage of the instanceof operator to determine if a class instance is an instance of a specific class:

class Simple1 extends Simple2{
   //do something meaningful here
}

class Simple2{
   //do something meaningful here
}

class CompClasses{
   Simple1 x = new Simple1();
   public static void main(String args[]){

   if(smp.x instanceof Simple2){
      // This is OK since 'Simple1' is a subclass of 'Simple2'
   }
}


Compiler Error J0228

Syntax error in @dll declaration

The compiler detected a syntax error in an @dll comment tag. This error usually occurs when an @dll comment tag has been mistyped. Check the statement for syntactical errors and compile again.

The following example illustrates this error:

public class Simple{
   /**@dll.import(kernel32, ansi)*/
   /* error: missing quotes around 'kernel32' */

   public static native boolean GetComputerName(StringBuffer s, int[]cb);
}


Compiler Error J0229

Expected string constant

The compiler detected that a string constant parameter of a comment tag's declaration (for example @com, @dll, or @security) was either missing the string constant or the string constant was incorrectly entered. This error most often occurs when matching quotes are missing around a value passed to an attribute. Check your comment tag declaration's attributes and compile again.

The following example illustrates this error:

/**@com.interface(iid=31415926-5358-9793-2384-612345678901,dual)*/
interface ITest{
   /**@com.method(name=method1);*/
   //error: Missing quotes around 'method1'
   public void method1();
}


Compiler Error J0230

Class or interface name 'identifier' conflicts with import 'identifier'

The specified class or interface conflicts with a class that has been imported. This can be caused by declaring a class or interface that is already declared in the Java API, and you are trying to import that API class or interface into your source file.

The following example illustrates this error:

import java.lang.Cloneable;

class Cloneable{ /*error Cloneable has already been
                         imported */
   //class implementation
}


Compiler Error J0231

Expression statement must be assignment, method call, increment, decrement, or "new"

The compiler detected an invalid expression statement. An expression statement is a statement that can reside on its own line of source code. The following are some examples of valid expression statements:

m_cars.changeColor(); //Method calls
int x = y + z; //Assignment statements
j++; //Increment statement
m_tempVar1 += 3;
new Simple();

The following are examples of invalid expression statements:

1+2;  //error: No assignment statement
j+k-method1();  //A method call but not a valid assigment statement
var1 == var2;  /*Comparison statements should be contained in flow
                 control statements*/


Compiler Error J0232

Expected '{' or ';'

The compiler detected an error with a method declaration in a class or interface. This error usually occurs if an interface's method declaration is missing a semicolon at the end of the declaration or a class's declaration is missing its opening brace '{'. Check the specified class or interface method declaration and for a missing semicolon or opening brace and compile again.

The following example illustrates this error:

interface ISimple{
   public void method1()
   //error: missing semicolon to end declaration
}

public class Simple{
   public void method1()
   //error: missing opening brace
}


Compiler Error J0233

Catch clause is unreachable; exception 'identifier' is never thrown in the corresponding try block

The compiler detected that the specified catch clause will never be executed because the corresponding try statement block never throws the catch statement's exception type. Catch statements are required to catch exceptions or derivations of exceptions that the try statement block can throw. This error can be avoided by changing the catch statement so it does not catch a specific exception type, but instead, catches the base Exception class. Change the exception class your catch statement will trap and compile again.

The following example illustrates this error:

class Simple{
   void method1(){
      int I = 0;
      try{
         I = I + 1; //This try block has nothing to do with clones
      }
      catch (CloneNotSupportedException c){
         //error: The exception type can never be caused by try block
      }
   }
}

The following example illustrates how to avoid this error by using the base Exception class:

class Simple{
   void method1(){
      int I = 0;
      try{
         I = I + 1; //This try block has nothing to do with clones
      }
      catch (Exception e){
         //This is OK since all exceptions must derive from this class
      }
   }
}


Compiler Error J0234

'identifier' is not a field in class 'identifier'

The compiler detected a field reference but the field does not exist in the specified class. This error usually occurs when the field reference is mistyped or the field reference was meant to reference a field in a different class. Ensure that the field exists in the specified class, that your reference to the field is syntactically correct, and compile again.

The following example illustrates this error:

public class Simple{
   int var1;
   public Simple(){
       this.var = 10;
       //error: 'var' is not a field in this class
   }
}


Compiler Error J0235

'identifier' is not a method in class 'identifier'

The compiler detected a method call but the method does not exist in the specified class. This error usually occurs when the method call is called incorrectly or the method call was meant to reference a method in a different class. Ensure that the method exists in the specified class, that your method call is syntactically correct, and compile again.

The following example illustrates this error:

class Simple{
   public void method1(){
      //do something here
   }
}

class Simple2{
   public void method1(){
      Simple smp = new Simple();
      smp.method2();
      //error: 'method2' does not exist in the class 'Simple'
   }
}


Compiler Error J0236

'identifier' is not a nested class or interface in class 'identifier'

The compiler detected a reference to a nested class or interface but the nested class or interface does not exist in the specified class. This error usually occurs due to a syntactical error in referencing a nested class or interface. Check the reference to the inner class for syntax errors and ensure that the class or interface exists inside the specified class, and compile again.

The following example illustrates this error:

class NotSimple{
}

public class Simple{
   void method1(){
      NotSimple nt = new NotSimple();
      Object o = nt.new InnerClass();
      //error: 'InnerClass' is not an inner class of 'NotSimple'
   }
}


Compiler Error J0237

'identifier' is not a field or nested class in class 'identifier'

The compiler detected a reference to a nested class or field but the nested class or field does not exist in the specified class. This error usually occurs due to a syntactical error in referencing a nested class or field. This error can also occur if a reference to a field in an inner class is made but the field does not exist within the inner class definition. Ensure that the inner class or field exists and compile again.

The following example illustrates this error:

class Simple1{
   int var1;
}

class Simple2{
   static class InnerClass{
      int var1;
   }
   static Simple1 smp;
}

public class Simple{
   void method1(){
      int x, y;

      x = Simple2.innerclass.var1; /*error: 'innerclass' is not name of
                                  an inner class. 'InnerClass' is */
      y = Simple2.smt.var1; /*error: 'smt' is not the name of a field in
                         'Simple2'. Should be 'smp' */
   }
}


Compiler Error J0238

Cannot throw exception 'identifier' from field initializer

The compiler detected that an exception was thrown within a field initializer. This error usually occurs when an exception is throwable from a constructor of a class, and an instance of that class is declared and instantiated as a member of another class. To resolve this problem, have the class object that throws the exception instantiated inside a constructor so it can use a try/catch combination to trap any exceptions from the other class's constructor call.

The following example illustrates this error:

public class Simple{
   public int i;
   public Simple(boolean var1) throws Exception{
      if (var1 = true)
         i = 0;
      else
         throw new Exception();
   }
}
//This is the incorrect way to instantiate this class
class Simple2{
   Simple smp = new Simple(true);
   /* error: cannot call constructor that throws exception in field
            initializer*/
}

The following code replaces the 'Simple2' class code in the example above to show the correct way to instantiate the 'Simple' class instance:

//This is the correct way to instantiate Simple
class Simple2{
   Simple smp;
   public Simple2(){
      try{
         smp = new Simple(true);}
      catch(Exception e){}
   }
}


Compiler Error J0239

Static initializer must assign a value to blank final variable 'identifier'

The compiler detected that a static final variable was not initialized to a value using a static or field initializer. In order to declare a variable as static and final you must use a static or field initializer to set an initial value. This error can also occur if a field is declared as static and final and assigned a value in a constructor.

The following example illustrates this error:

public class Simple{
   static final int MAX_CONTROL;
} //error: static final variables must have value assigned


Compiler Error J0240

Syntax error in @security declaration

The compiler detected a syntax error in the specified @security comment tag. This error usually occurs when the comment tag is missing a closing parenthesis or the tag's attributes are incorrect. Ensure the syntax of the specified @security comment tag declaration is correct and compile again.

The following example illustrates this error:

/**@security()*/   //error: invalid @security syntax
public class Simple{
   //class members defined here
}


Compiler Error J0241

'@security' can only be specified on a class or interface

The compiler detected that the @security comment tag was applied to something other than a class or interface declaration. The @security comment tag is used to define the security settings for a class or interface definition and cannot be applied to methods or fields of a class or interface.

The following example illustrates this error:

public class Simple{
   /**@security(checkDllCalls=on)*/
   public void method1(){
   //error: cannot use @security tag on method
   }
}


Compiler Error J0242

Cannot make static call to non-static method 'identifier'

The compiler detected that a method was called by using the static method call syntax '<classname>.<method>', but the method is not a static method. Change the method call to use an instance of the class that contains the method instead of the class name itself and compile again.

The following example illustrates this error:

public class Simple{
   public void method1(){
      //do something here
   }
}

class NotSimple{
   public void methodx(){
      Simple.method1();
      //error: 'method1' is not a static method
   }
}


Compiler Error J0243

'identifier' is obsolete; use 'identifier' instead

The compiler detected a comment tag (for example @com, @dll, @security) that is using a format that is now considered obsolete. To avoid this error change the line of code that the error occurred on to the newer format specified in the error message and compile again.

The following example illustrates this error:

public class Simple{
   /**@dllimport("kernel32", ansi)*/
   /* error: 'dllimport' is no longer a supported format for
      @dll.import declarations */
   public static native boolean GetComputerName(StringBuffer s, int[]cb);
}


Compiler Error J0244

@conditional allowed only on void-returning methods

The compiler detected an @conditional comment tag for a method that has a non-void return value. The @conditional comment tag can only be used for methods without a return value. Change the method declaration to return void or remove the @conditional comment tag and compile again.

The following example illustrates this error:

public class Simple{
   /**@conditional(DEBUG)*/
   public int method1(int x){
      //error: conditional methods cannot return a value
   return x * 2;
   }
}


Compiler Error J0245

Warning treated as error

The compiler was run using the /wx switch, and a warning was found during compilation. The /wx compiler switch treats all warnings as errors. In order for the /wx compiler switch to display this error, the warning level switch (/w{0-4}) must be set high enough to display the warning. Determine the cause of the warning and compile again. You can also remove this switch from your compiler options and compile again.


Compiler Error J0246

Invalid token on a # directive

The compiler detected an invalid token for a conditional compilation expression. This error usually occurs when a token is mistyped or the token used is not a legal token. Ensure that the conditional compilation directive specified in the error is correct and compile again.

The following example illustrates this error:

public class Simple{
   public void method1(){
      #iff DEBUG //error: 'iff' is not a valid token
        System.out.println("Do something meaningful here");
      #endif
   }
}


Compiler Error J0247

#elif without matching #if

The compiler detected a #elif conditional compilation directive, but did not detect a matching #if directive. Ensure that you have a valid #if conditional compilation directive to match your #elif directive and compile again.

The following example illustrates this error:

public class Simple{
   public void method1(){
      //error: need to have '#if' before '#elif'
      #elif DEBUG
         System.out.println("Do something meaningful here");
      #endif
   }
}


Compiler Error J0248

#endif without matching #if

The compiler detected a #endif conditional compilation directive, but did not detect a matching #if directive. This error usually occurs because an extra #endif directive was supplied. This error can also occur when a #if conditional compilation directive was deleted or commented out but the matching #endif directive was not deleted. Ensure that you have matching directives and compile again.

The following example illustrates this error:

public class Simple{
   public void method1(){
      //#if SIMPLE
      //do something here
      #if DEBUG
          //do something here
          #if WIN95
             //do something here
          #endif
      #endif
      #endif //error: extra '#endif' directive not permitted
   }
}


Compiler Error J0249

#else without matching #if

The compiler detected a #else conditional compilation directive but, did not detect a matching #if directive. This error usually occurs because an extra #else directive was supplied. This error can also occur when a #if conditional compilation directive was deleted or commented out but a #else directive was not deleted. Ensure that you have matching directives and compile again.

The following example illustrates this error:

public class Simple{
   public void method1(){
      //do something here
      #else /*error: this '#else' directive has no matching '#if'
              directive */
   }
}


Compiler Error J0250

Already had an #else

The compiler detected a duplicate #else conditional compilation directive in a #if directive block. A #if directive can only have one #else directive. Ensure that you have only one #else conditional compilation directive for the #if directive in which the error occurred and compile again.

The following example illustrates this error:

public class Simple{
   #if A
     #if B
     void method1{
       //do something here
     }
   #else
     void method2{
       //do something here
   #else  //error: extra '#else' directive supplied
   #endif
}


Compiler Error J0251

Unexpected EOF while looking for #endif

The compiler detected a #if conditional compilation directive but did not find a matching #endif directive, and the symbol used by the #if directive was not defined. This error usually occurs when a #if conditional compilation directive is used but a matching #endif directive was not defined to close the conditional compilation block. Ensure that you have a matching #endif directive for the #if directive specified in the error and compile again.

The following example illustrates this error:

public class Simple{
   void method1(){
      #if DEBUG //debug has not been defined
         System.out.println("Do something here");
   //error: '#endif' not specified for the '#if' directive
   }
}


Compiler Error J0252

#if nested too deeply

The compiler detected nested #if conditional compilation blocks that were nested too deeply. Nesting of #if conditional compilation blocks is limited to 64 levels. Ensure that your nesting of #if blocks is within the limit and compile again.


Compiler Error J0253

Cannot have #define/#undef after source

The compiler detected a #define or #undef conditional compilation directive after other Java source code. The #define and #undef directives must be placed before other Java source code (except for other conditional compilation directives and source comments). Move the #define or #undef directive indicated by the error to the front of all Java source code in the file and compile again.

The following example illustrates this error:

package boxes;

#define DEBUG
//error: '#define' must occur before the 'package' statement

public class Simple{
}


Compiler Error J0254

Cannot change predefined symbol

The compiler detected an attempt to use the #define or #undef directive on a symbol already defined in Java. This error occurs when a symbol such as true or false, which are already defined for conditional compilation, is redefined using the #define or #undef conditional compilation directives. Remove or change the #define or #undef directives specified in the error and compile again.

The following example illustrates this error:

#undef false //error: cannot undefine the 'false' symbol
#define true //error: cannot define the predefined 'true' symbol

public class Simple{
   //do something here
}


Compiler Error J0255

Expected #endif

The compiler detected a #if conditional compilation directive but did not find a matching #endif directive; however, the symbol used by the #if directive was defined. This error usually occurs when a #if conditional compilation directive is used but a matching #endif directive in not defined to close the conditional compilation block, and the code is intended to be compiled. Ensure that you have a matching #endif directive for the #if directive specified in the error and compile again.

The following example illustrates this error:

#define DEBUG

public class Simple{
   void method1(){
      #if DEBUG
         System.out.println("Do something here");
   //error: '#endif' has not been specified for the '#if' directive
   }
}


Compiler Error J0256

Expected 'class', 'interface', or 'delegate'

The compiler expected to find the class, interface, or delegate keywords used within the corresponding declaration. This error usually occurs when the keywords are accidentally omitted from a class, interface, or delegate declaration. Another possible cause of this error is unbalanced scoping braces.

Note This error will only occur if the Microsoft Extensions are enabled in your project. Otherwise, compiler error J0020 will be displayed.

The following example illustrates this error:

public Simple{ //error: missing the 'class' keyword
   //Do something here
}

This example illustrates this error caused by unbalanced scoping braces:

public class Simple {

   // do something meaningful

}}   // error: additional '}' is not permitted


Compiler Error J0257

Delegate cannot be initialized with static method 'identifier'

The compiler detected a delegate instantiation but the method reference, passed as a parameter, was a static method. When instantiating a delegate, you must pass a non-static method as a parameter. Ensure that the method you are defining the delegate to use is a non-static method and compile again.

The following example illustrates this error:

delegate int MyDelegate (int var1, String var2)throws Exception;

public class Simple{

   public static int method1(int var1, String var2) throws Exception{
      //do something here
      return var1;
   }

   public static void main (String args[]){
      Simple smp = new Simple();
      MyDelegate md = new MyDelegate(smp.method1);
      /*error: the method passed as a parameter to the delegate is a
               static method */
   }
}


Compiler Error J0258

Cannot declare delegate in inner class 'identifier'

The compiler detected an attempt to declare a delegate inside an inner class. Inner class definitions do not support delegates declared within them. Remove the delegate declaration from within the inner class declaration and compile again.

The following example illustrates this error:

public class Simple{
   //Do something meaningful here
   class InnerClass{
   //Do something meaninful here
      delegate int MyDelegate (int var1, String var2);
         /*error: delegates cannot be declared
                  inside inner classes */
   }
}


Compiler Error J0259

Exception 'identifier' from method 'identifier' is not a subclass of any exceptions declared thrown by delegate 'identifier'

The compiler detected a delegate that was initialized with a method that throws an exception that is incompatible with the delegate's declared set of exceptions. Each exception thrown by the method must be the same class or a subclass of an exception that the delegate throws. Change the set of exceptions thrown by either the delegate or the method and compile again.

The following example illustrates this error:

delegate void SimpleDelegate(String var1) throws Exception;

public class Simple{
   public void method1(String var1) throws Throwable{
      //do something here
   }
   public static void main (String args[]){

      Simple smp = new Simple();
      SimpleDelegate del1 = new SimpleDelegate(smp.method1);
      /* error: the method reference argument throws an exception that is
             not the same or a subclass of the exception declared by the
             delegate */
   }
}


Compiler Error J0260

Cannot declare an interface method to be 'protected' or 'private'

The compiler detected an interface with a method declared as protected or private. Interface methods must be declared as either public or with no access modifier (default). Change the interface method declaration specified in the error so that it is not declared protected or private and compile again.

The following example illustrates this error:

interface ISimple{
   public void method1(); //this is OK!
   void method2(); //this is OK! Declared as "default" access
   protected void method3(); /*error: cannot declare interface method as
                                      protected */
   private void method4(); /*error: cannot declare interface method as
                                    private */
}


Compiler Error J0261

An explicit enclosing instance of class 'identifier' is needed to instantiate inner class 'identifier'

The compiler detected an attempt to create an instance of an inner class without specifying an instance of its enclosing class. This error usually occurs when an attempt is made, within a static method, to instantiate an inner class as you would an outer class. To create an instance of an inner class, you must use an existing instance of its outer class. Create an instance of the enclosing class and use it to instantiate the inner class and compile again.

The following example illustrates this error:

public class Simple{
   class InnerClass{
      //do something here
   }

   public static void main(String args[]){
      InnerClass inc = new InnerClass();
      /*error: an instance of the outer class is required to instantiate
               its inner class */
   }
}

The following example illustrates how to create an instance of an inner class using an instance of its outer class:

public class Simple{
   class InnerClass{
      //Do something here
   }
   public static void main(String args[]){
      Simple smp = new Simple();
      /*use the instance of 'Simple' to create an instance of its inner
        class*/
      InnerClass inc = smp.new InnerClass();
   }
}


Compiler Error J0262

An explicit enclosing instance of class 'identifier' is needed to call constructor of superclass 'identifier'

The compiler detected an attempt by a derived class to call its superclass constructor without an instance of the superclass. This error usually occurs because the superclass is also an inner class. When a derived class is instantiated, an instance of its superclass is also created (and the superclass constructor is invoked). In order to create an instance of an inner class you must instantiate the inner class using an instance of its outer class.

The following example illustrates this error:

class OuterClass{
   class InnerClass{
   //do something here
   }
}

public class Simple extends OuterClass.InnerClass{
   //do something here
}
/*error: superclass 'InnerClass' cannot be instantiated without its outer class 'OuterClass' being instantiated */

The following example illustrates how to instantiate a class that is derived from an inner class:

class OuterClass{
   class InnerClass{
   //do something here
   }
}

public class Simple extends OuterClass.InnerClass{
   Simple(){
      /*this line creates an instance of the outer class and calls
        the superclass (the inner class) constructor */
      new OuterClass().super();
   }
}


Compiler Error J0264

Array cannot have a dimension

The compiler detected an attempt to initialize an array dimension incorrectly. This error usually occurs when an array dimension size is specified before the instance is created. This error can also occur when an array is given a dimension in the proper place but an initialization list is also provided to set the values of the array (you cannot specify an array size for the dimension when using an initialization list). Correct the initialization of the array specified by the error and compile again.

The following example illustrates this error:

public class Simple{
   public void method1(){
      String[3] var1; /* error: cannot specify array size here since
                         array is not instantiated yet */
      String[] var2 = new String[3]; //this is OK!

      boolean var3 = new boolean[3]{true,false,true};
      /*error: cannot specify an array size for the dimension when using
               an initialization list */
      boolean var4 = new boolean[]{true, false,true}; //this is OK!
   }
}


Compiler Error J0265

@dll attribute cannot be placed on method 'identifier' — it must be declared 'native'

The compiler detected an @dll comment tag placed on a method that is not declared with the native modifier. This error usually occurs if an @dll comment tag is defined but the method it was applied to was removed or commented out, and other methods in the class can have the comment tag applied to them. Ensure that the method declared with the @dll comment tag is declared as native or remove the @dll comment tag and compile again.

The following example illustrates this error:

public class Simple{
   /** @dll.import("USER32") */
   //private native static int MessageBox(int hwndOwner, String text,
                                          String title, int fuStyle);

   /*error: the @dll comment tag cannot applied to 'method1' which is a
            non-native method instead of the intended native method*/
   public void method1(){
     //do something here
   }
}


Compiler Error J0266

Compilation canceled by user

The user canceled compilation. This error simply informs the user that the request to cancel compilation was successful.


Compiler Error J0267

A delegate cannot be 'identifier'

The compiler detected an attempt to declare a delegate with an invalid modifier. Only the public and final modifiers can be applied to a delegate declared outside of a class. A delegate declared within a class can have the public, final, protected, and private modifiers applied. Ensure that your delegate declaration is not using an invalid modifier and compile again.

Note Although you can use the final modifier in a delegate declaration, it is not needed as delegates are implicitly final.

The following example illustrates this error:

private delegate void Simple(int var1, int var2);
//error: cannot declare a delegate as 'private'


Compiler Error J0268

A delegate cannot be 'identifier' and 'identifier'

The compiler detected a delegate declaration, within a class, attempted to use a combination of access modifiers that are not allowed. This error usually occurs when a delegate is declared with two access modifiers applied. Remove the additional access modifier applied to the specified delegate declaration and compile again.

The following example illustrates this error:

public class Simple{
   public private delegate void SimpleDelegate();
   //error: cannot declare a delegate to be 'public' and 'private'
}


Compiler Error J0269

Ambiguous name: inherited 'identifier' and outer scope 'identifier' — an explicit 'this' qualifier is required

The compiler detected reference to a variable or method from within an inner class that is defined in both its outer class and its superclass. The compiler cannot determine which variable or method is to be used. You can reference the outer class variable or method by using class.this.name, where class is the name of the outer class whose variable or method you wish to reference and name is the variable or method name. To reference the superclass variable or method you can use the this super keyword before the reference.

The following example illustrates this error:

class NotSimple{
   int var1 = 20;
}

public class Simple{
   int var1 = 10;
   class InnerClass extends NotSimple{
      int var2 = var1;
      //error: cannot determine which 'var1' to use
   }
}

The following example illustrates how to resolve name ambiguity between the outer class and superclass variables:

class NotSimple{
   int var1 = 20;
}

public class Simple{
   int var1 = 10;
   class InnerClass extends NotSimple{
      int var2 = Simple.this.var1;
      //this is OK and references the outer class variable
      int var3 = super.var1;
      //this is OK and references the superclass variable
   }
}


Compiler Error J0270

The compiler detected an ambiguous reference to a field. This error usually occurs when a class's superclass and an interface the class implements have the same field declared. The compiler cannot determine which instance of the field to use. Ensure that you do not have a superclass and implemented interface that have the same field defined and compile again.

The following example illustrates this error:

public class Simple extends SuperClass implements SuperInterface{
   public static void main (String args[]){
      float x = var1; /*error: cannot determine which instance of 'var1'
                               to use */
   }
}

class SuperClass{
   float var1;
}

interface SuperInterface{
   float var1=6.0f;
}


Compiler Error J0271

Expected 'delegate'

The compiler detected the multicast modifier but did not detect the delegate keyword. The multicast modifier can only be used in conjunction with the delegate keyword to create multicast delegates. Ensure that you have the delegate keyword in the declaration specified by the error message and compile again.

The following example illustrates this error:

public multicast void SimpleDelegate(String x, int y);
//error: the 'delegate' keyword is missing after the 'multicast' modifier
public class Simple{
   //Do something here
}


Compiler Error J0272

A multicast delegate cannot return a value

The compiler detected a return type other than void for a multicast delegate declaration. Although delegates can return a value other than void, multicast delegates cannot return a value other than void. Ensure that the multicast delegate declaration specified by the error returns void and compile again.

The following example illustrates this error:

multicast delegate int SimpleDelegate(int x, int y);
//error: cannot declare multicast delegate with non-void return type
public class Simple{
   public int method1(int x, int y){
      //Do something here
   }

   public static void main (String args[]){
      Simple smp = new Simple;
      SimpleDelegate sd = new SimpleDelegate(smp.method1);
   }
}


Compiler Error J0273

The compiler detected an attempt to cast the return value of a method call to void. Casting a method call to void is not allowed in the Java language. Remove the void cast for the method call specified by the error and compile again.

The following examples illustrates this error:

public class Simple{
   public void method1(){
      //Do something meaningful here
   }
   public static void main (String args[]){
      Simple smp = new Simple();
      (void) method1();
      //error: cannot cast method's return value to 'void'.
   }
}


Compiler Error J0274

Expected 'identifier' within single comment preceding class 'identifier'

The compiler detected that the class, specified in the error message, was declared with either the @com.typeinfo or @com.transaction comment tag and a corresponding @com.register comment tag was not found within the same comment. This error can occur when an @com.register comment tag is declared but is within a separate comment. Ensure that an @com.register comment tag is defined within the same comment as the @com.typeinfo or @com.transaction comment tags defined for the class specified in the error message and compile again.

The following example illustrates this error:

/** @com.register ( clsid=AE032C46-E6A0-11d0-8C83-00C04FC2AAE7) */
/** @com.typeinfo(attrid=31415926-5358-9793-2384-612345678901,
value="Help") */
public class Simple{
   /error: the '@com.register' tag is ignored since it is in a separate
           comment */
}

/** @com.register ( clsid=AE032C46-E6A0-11d0-8C83-00C04FC2AAE7)
    @com.typeinfo(attrid=31415926-5358-9793-2384-612345678901,
value="Help")*/
public class Simple2{
   //This comment is OK. It combines both tags in a single comment.
}


Compiler Error J0275

Class or interface name 'identifier' conflicts with package 'identifier'

The specified class or interface name conflicts with a package name. This error can be caused by declaring a class or interface within a package with the same name as a subpackage. Rename either the subpackage or the class or interface that is causing the ambiguity and compile again.

The following example illustrates this error:

//located in a file called Plastic.java
package Boxes.Dishes;
public class Plastic{
   //do something here
}

//located in a file called Dishes.java
package Boxes;
public class Dishes{
   //error: the name 'Dishes' is also the name of the subpackage
}


Compiler Error J0500

#error 'user defined error'

This error message is generated when there is a #error conditional compilation directive in the program.

The following example illustrates this error:

#define DEBUG
public class Simple{
   public void method1(){
      #if DEBUG
         #error You should not be running in debug mode here!
         //error: displayed when 'DEBUG' is defined
      #endif
   }
}


Compiler Warning J5001

Local variable 'identifier' is initialized but never used

The compiler detected an initialized variable that was not referenced in any class code. This message occurs at warning level 3 or greater. Use the variable or remove its declaration.

The following example illustrates this warning:

public class Simple {

   public int method1() {

      int i = 1;
      return 1;
      // warning: 'i' is never used
   }
}


Compiler Warning J5002

Compiler option 'identifier' is not supported

The compiler detected that an unsupported command line option was specified. Check your compiler switch settings and compile again.


Compiler Warning J5003

Ignoring unknown compiler option 'identifier'

The compiler detected an unknown option specified on the JVC command line. This warning usually occurs when a typographical error exists. For example, specifying /W4 on the command line will cause this warning because the warning level option must use a lowercase 'w'.


Compiler Warning J5004

Missing argument for compiler option 'identifier'

The compiler detected a valid command line option, but the required argument was not specified. Check your compiler switch settings and compile again.


Compiler Warning J5005

Package 'identifier' was already implicitly imported

The compiler detected an import statement for a package that was already implicitly imported, such as java.lang. This message occurs at warning level 1 or greater.

The following example illustrates this warning:

import java.lang.*;
//warning: process is already imported in the first import statement
import java.lang.Process;

public class Simple{
   //Do something meaningful here
}


Compiler Warning J5006

'private protected' not supported, using 'protected'

The compiler detected use of the modifier combination private protected. This combination is now obsolete and has been replaced by protected. This message occurs at warning level 1 or greater.


Compiler Warning J5014

'identifier' has been deprecated by the author of 'identifier'

The method or class referenced has been marked as deprecated. Deprecated methods or classes are marked by the creator of the source code as outdated and subject to removal. To keep code stable, avoid calling functions that have been flagged as deprecated.


Compiler Warning J5015

The parameter 'identifier' in an @com.parameters declaration does not match the corresponding argument 'identifier'

An @com.parameters declaration does not match the method that implements the interface. This error could indicate data type inconsistencies or mismatched parameter locations. Ensure that your @com.parameters declaration has the same number of parameters, the correct types, and correct order with the method being declared and compile again.

The following example illustrates this warning:

/** @com.interface(iid=31415926-5358-9793-2384-612345678901, dual) */
interface ExampleInterface
{
/**
@com.method(dispid=306)
@com.parameters([type=BOOLEAN] when, on)
*/
//error: @com.parameters declaration has parameters in wrong location

public String Method1(boolean on, int when);
}


Compiler Warning J5016

This 'instanceof' operator will always be true

The compiler determined that the specified instanceof expression will always evaluate to true. This can occur when instanceof is used to determine if a subclass instance is a member of a base class or an implemented interface. Although it is not an error to use the instanceof operator in this fashion, it's not particularly useful since the expression will always evaluate to true.

The following example illustrates this warning:

interface I {}
class X {}
class Y extends X implements I {}

public class Simple{
   void f()
   {
      Y y = new Y();
      X x = new X();
      Object o;

      // These statements give J5016 warnings...
      if (y instanceof X){
         // y is of type Y, which extends X, so this is always true
      }
      if (y instanceof I){
         // type Y implements I, so this is always true.
      }
      if (x instanceof Object){
         // everything is of type Object
      }
   }
}


Compiler Warning J5018

Class, interface, or package name contains characters not in the ASCII character set

The compiler detected a character that is not in the ASCII character set used for a class, interface, or package name. Some computer systems may not support this character. To ensure that your class, interface, or package name can be interpreted by Virtual Machines (VM) on other computer systems, change the invalid character to a valid character from the ASCII character set and compile again.


Compiler Warning J5019

Public member of COM-exposed class or interface contains characters not in the ASCII character set

The compiler detected a character that is not in the ASCII character set used for a method or field that is accessible to other languages via COM. Other languages may not support this character. To ensure that your member name can be accessed from other languages, change the character to a valid character from the ASCII character set and compile again.


Compiler Warning J5020

Directive 'identifier' ignored -- extensions are turned off

The compiler detected a comment tag such as @com or @dll applied in your source code but Microsoft Language Extensions were disabled. In order to use comment tags and other Microsoft Language Extensions, the extensions option must be enabled.

! WARNING With the Microsoft Language Extensions option disabled, any code that utilizes Microsoft Language Extensions may not work correctly.

The following example illustrates this warning:

//Microsoft Language Extensions are 'disabled'
public class Simple{
   /**@dll.import("User32")*/
   public static native int MessageBox(int hWnd, String text, String
                                       caption, int type);
   //warning: the 'MessageBox' method may not work correctly


Compiler Warning J5021

Package 'identifier' should not be defined in directory 'identifier'

The compiler detected a package statement in your source file but the directory name where the source file resides does not match the package statement. Although the source code will compile, other source files will not be able to reference classes, interfaces, and delegates defined in this source file using the package name.

The following example illustrates this warning:

//source file resides in c:\files\simple
package boxes; //warning: package 'boxes' does not match directory name
'simple'
public class NotSimple{
  //warning: this class is not accessible using the current package name
}


Compiler Warning J5022

Referenced class file 'filename' may be older than 'filename'

The compiler detected a class file, which is referenced by the source file being compiled, that is out of date or not found. This warning usually occurs when automatic re-compilation of referenced classes has been disabled (using the ref- compiler option). If you are compiling within Visual J++, the ref- option is passed to the compiler by default. If any of your source files reference a class file that is not in your project and the file is out of date with its source, you will need to update the referenced class files. You can either recompile the external class files to make them up to date, add the external files to your project, or add the ref compiler option. You can add the ref compiler option by entering it in the Additional Compiler Options text box in the Compile tab of the Project Settings dialog box.


Compiler Warning J5023

File 'filename' has more than 65535 lines--debug information may be incorrect

The compiler attempted to place debugging information in a source file that contains more than 65535 lines of code. Your code may compile, however; not all the debugging code needed for your application will be contained in this file. Reduce the size of your source file so that the debugging information can be added and compile again.


Compiler Warning J5024

Package 'identifier' was already imported

The compiler detected a package imported more than once in the specified source file. Although this will not cause the compiler to fail, you should remove the extra import statement for the package specified in the warning message.


Compiler Warning J5500

#warning 'user defined warning'

This warning message is generated when there is a #warning conditional compilation directive in the program.

The following example illustrates this error:

#define DEBUG
public class Simple{
   public void method1(){
      #if DEBUG
         #warning You are compiling for debug mode
         //warning: displayed when 'DEBUG' is defined
      #endif
   }
}


COM Registration Errors (Visual J++)

During registration of a COM class, you may be prompted with an error or warning message. The following is a list of the more common errors and warnings. Each error or warning includes information as to the possible reasons the error occurred and, where applicable, suggestions on how to resolve the error or warning.

No registration attribute in class file 'filename'

Registration of the class file referenced in the error message was attempted but the class file did not contain a @com.register comment tag. Ensure that the COM class in the class file you are attempting to register has a valid @com.register comment tag.

Cannot create instance of class 'identifier'

In order to create a type library and register your COM class, a class must be able to be instantiated and call the standard constructor (the constructor that does not contain any parameters). This error can occur if any dependent classes of your COM class cannot be located or if there is an error in the standard constructor for your class. Ensure that the dependent classes for your COM class can be accessed and that your class's standard constructor contains no errors.

Cannot open filename 'filename'

During the COM registration process, a temporary type library file is generated. This error occurs when the temporary filename cannot be copied and renamed to the final type library name. Ensure that the file is not read-only, in a read-only directory, or in use by another application.

Unable to create registry keys for class 'identifier'

While attempting to register your COM class, the COM registration process could not create a key in the system registry. This error can also occur if the COM registration process cannot open a specific key or write a value into the registry. Ensure that your system registry is not damaged.

Class file 'filename' does not have the extension '.class'

In order to register a COM class, the compiled class file must have the .class extension. This error can also occur if the file to be registered as a COM class is not a valid Java class file. Ensure that the class file you are attempting to register as a COM class contains the .class extension and that it is a valid Java class file.

The internal class name 'identifier' does not match the file or directory name of class file 'filename' — it cannot be loaded

The COM class that is being registered has a different class name than the class file it is located in, or the class file is located in a directory that conflicts with the class's defined package. Ensure that the COM class name and its defined package match the location and name of the class file.

Classes contain more than one type library id. Only one type library can be created at a time

Only one type library can be specified in your Visual J++ project at a time. This error usually occurs when a COM class's @com.register comment tag has a different typelib GUID than the other COM classes in your project. All COM classes in a project must have the same typelib GUID specified. You can resolve this conflict by clearing the check box next to the class in the COM Classes tab of the Project Properties dialog box, apply the changes, and then recheck the check box for the class. This will reassign the class as a COM class and specify the same typelib GUID.

Base name of class 'identifier' conflicts with another class in the same type library

A class was found that was defined already within the type library. This error usually occurs when a COM class is defined in one package, and a COM class, with the same name, in a different package are both being added to the same type library. Change the name of one of the classes being added to the type library so that the conflict is resolved.


Windows EXE/COM DLL Packaging Errors (Visual J++)

During the creation of a Windows EXE or COM DLL, you may be receive an error message. The following is a list of the error messages that might occur. Each error includes information as to the possible reasons the error occurred and, where applicable, suggestions on how to resolve the error.

Path too long: 'path'

The path and filename of a Windows EXE or COM DLL is larger than 256 characters. Reduce the size of the path and filename and rebuild your project.

No main class file specified

An attempt was made to create a Windows EXE but a main class (a class with a main method defined) was not specified. In order for a Windows EXE to be created, you must specify a main class in the Launch tab of the Project Properties dialog box.

No class files found

An attempt was made to create a Windows EXE or COM DLL but no class files were found or specified to create the EXE or DLL. Ensure that your project contains at least one class file and that a class file is specified in the Output Format tab of the Project Properties dialog box.

Unable to open output file: 'filename'

The file specified in the error message could not be opened. Ensure that the specified file is not read-only or in use by another program. This error can also occur if the specified file is located in a directory in which you do not have write permission.

Unable to update resources in file: 'filename'

An attempt was made to write resource information to the resource file specified in the error message, but was unable to update the resource file. Ensure that you have enough available free disk space on your computer.

Badly formatted class file: 'filename'

The class file specified in the error message is in an invalid format. This error usually occurs when a class file is damaged or is a file with the class extension, but is not a valid Java class file. Delete the class file specified in the error message and rebuild your project.

File not found: 'filename'

The file specified in the error message was not found. Ensure that the proper location of the file is specified in the Output Format tab of the Project Properties dialog box and rebuild your project.

Unable to load resources from file 'filename'

The resource file specified in the error message could not be opened. Ensure that the resource file is a valid Windows resource file and that the resource file is not in use by another program.

Unable to read typelib file 'filename'

The type library file specified in the error message could not be opened. Ensure that the type library file is a valid type library file and that the file is not in use by another program.

Corrupt registration attribute in class 'identifier'

A COM registration attribute for the class specified in the error message is corrupt. This error usually occurs when the class file for the specified class is damaged or in an invalid file format. Delete the class file for the specified class and rebuild your project.

Class 'identifier' does not have a method of the form 'static public void main (String[])'

A class was specified as the main class of a Windows EXE, but the class did not contain a main method. The main method provides a starting point for the Windows EXE and must be specified. Add a main method to the class specified in the error message or choose a different main class in the Launch tab of the Project Properties dialog box and rebuild your project.

Main class name 'identifier' is too long

The main class name specified in the error message is larger than 256 characters. Reduce the size of the class name and rebuild your project.

Specified main class 'identifier' not found

While creating a Windows EXE file, the class specified as the main class for the Windows EXE was not found. This error usually occurs when a main class was specified in the Launch tab of the Project Properties dialog box, but the main class has been removed or renamed from the class file. Specify a new main class in the Launch tab of the Project Properties dialog box and rebuild your project.

Unable to read from file 'filename'

The file specified in the error message could not be opened for reading. Ensure that the specified file is not in use by another program.

Cannot create a DLL with no COM classes

An attempt was made to create a COM DLL, but the project does not contain any COM classes. You can create a COM class by selecting a class from the list of classes in the COM Classes tab of the Project Properties dialog box. If you do not wish to expose any of your classes as COM classes, change the type of package you want to create in the Output Format tab of the Project Properties dialog box and rebuild your project.

Failure during auto-registration of 'filename'

A COM DLL failed to auto-register after being created. This error usually occurs when the system registry is damaged.

Out of memory

Insufficient memory was available when creating a Windows EXE or COM DLL. Close other programs that are currently running to provide more available memory and rebuild your project.


Class Outline

Class Outline provides a graphical tool for navigating and manipulating the interfaces, delegates, classes, and class members of the individual Java source files in your project. It provides the ability to quickly gain access to elements in your classes and other files that are related to your classes.

With Class Outline you can:

  • Double-click a class, interface, delegate, method, or field name to take you to the section of the source file where the selected element is defined.

  • Double-click a package class, imported class, superclass, implemented interface, or inherited member to take you to its source code, if available, or to its entry in the Object Browser.

  • Use the shortcut menus to set breakpoints on class members.

  • Use the shortcut menus to override superclass members inherited by your class.

  • Use the shortcut menus to cut, copy, paste or delete classes, delegates, interfaces and their members from the source file.

  • Use the shortcut menus for adding classes and members to the source file.

Elements

The Class Outline is displayed when a Java source file is opened for editing. The Class Outline tree contains nodes for each class, delegate, and interface found in the source file. The following is a list of the nodes and items that can be found in the Class Outline, depending on the code in your source file.

Package Node

The first node in the tree is the Package node. It is labeled as Default Package (when the source is not in a specific package) or it has the name of the package as defined by the package declaration in your source code. If the source file is a member of a specific package, the node expands to display all the class names in the package. Otherwise, the package node displays all the classes in the project directory.

Imports Node

The Imports node displays all the classes that are imported using the import keyword in the source file. This node is not visible if the source file does not import other classes.

Class and Interface Nodes

Each class, delegate, and interface that are defined in the current source file is listed as a node in the Class Outline tree. Expanding a class, delegate, or interface node displays the methods and fields that are defined in the class, delegate, or interface definition. An icon is associated with each member to identify its access level and member type. See Class Outline Icons for a list of the icons and their meanings.

Superclasses

The Superclasses node is displayed under each class and lists all the classes that the current class extends, explicitly or not.

Inherited Members

The Inherited members node is displayed under each class and provides a list of all the methods that the class has inherited from its superclasses.

Implemented Interfaces

The Implemented Interfaces folder is added if a class implements any interfaces. The names of the interfaces that the class implements are displayed in this folder.

Nested and Member Classes

The Nested or Member Classes node is added if a class has any nested classes or interfaces defined in its implementation. When a nested class or interface node is expanded, it displays the same information that an outer class or interface displays.

Note Nested classes and interfaces that are defined within a method are not displayed, since they are local to the method.

Initializers

The Initializers folder is displayed if a class declaration includes any initializer blocks. This folder contains a list of the static and instance initializers in the selected class. Each initializer item displays the intializer's type and a section of the initializer code.

Javadoc Pane

If a class is selected that contains Javadoc comments, the Javadoc pane (located below the Class Outline tree) displays the first sentence of the comment.

Class Outline Icons

Icons are used throughout Class Outline to help identify elements of the source file. The following table identifies each icon and its meaning in the Class Outline.

Icon | Meaning
 | Package
 | Imported Package
 | Imported Class
 | Class
 | Interface
 | Superclass
 | Delegate
 | Inherited Method
 | Inherited Variable
 | Member Class
 | Initializer
 | Variable
 | Method
 | Protected Access
 | Private Access
 | Package Access
 | Error (This icon is displayed when a superclass or implemented interface could not be found)
 | Circular Reference (This icon is displayed when a class is its own superclass)


Project Explorer (Visual J++)

Project Explorer is a graphical navigation tool for accessing the different files in your Visual J++ project.

Project Explorer allows you to view the files that make up your project. Because Visual J++ projects are directory based, Project Explorer is dynamic. Files that are added to your Visual J++ project directory are automatically added to Project Explorer. When directories are added to a Visual J++ project, Project Explorer treats the directory as a package where groups of source files and other project support files can be added and maintained.

When a Visual J++ project is selected in Project Explorer you can:

  • Open a source file in either the source editor or the graphical editor (if the source file supports graphical editing).

  • Use the shortcut menus to add a package to a project.

  • Display all files in your project directory or only those that are considered part of your project.

  • Display a project in one of two views, Directory View or Package View.

  • Use the shortcut menus to add, remove, or delete items from a project.

  • Use the shortcut menus to set configuration options for a project.

Views

Two views are available in Project Explorer when a Java project is selected: Package View and Directory View. The views are designed to make finding elements of a project easier. You can change the view to Directory View by clicking the Directory View button in Project Explorer or by clicking Directory View on the Project menu. You can change the view to Package View by clicking the Package View button in Project Explorer or by clicking Package View on the Project menu.

Directory View

The default view for Project Explorer is Directory View. It displays the editable files and directories that make up your Visual J++ project structure. Files that are not directly editable in Visual J++ are filtered out by default. You can view all the files that are in your project directory structure, including files that are filtered out, by selecting the Show All Files button or clicking Show All Files from the Project menu. Files can be removed from the project, but kept in the project's directory structure. To remove a file from the project right-click on the file you wish to remove and click Remove From Project on the shortcut menu. When a file is removed from a project, its icon is shaded and cannot be opened for editing in Visual J++. If you want to add a file that is not currently in your project but is located in your project directory, click the Show All Files button to display all files in your project directory structure. Right-click on the file that you want to add to your project, and then click Add To Project on the shortcut menu. The file is now added to your project.

Package View

Package View displays all the packages in your project and their source files. Unlike Directory View, packages located under the project directory are not displayed as sub-items of the project, but instead are displayed as items directly under the project name. Each package is displayed using the package's declared name (for example PackageA.PackageB) instead of just the directory name in which the package's source files are located. Package View allows you to view the project as another Java program would view your project — as a group of packages. Also, unlike Directory View, Package View only displays Java source files. Non-Java source files are filtered out in Package View. If a non-Java source file is added while in Package View, the file will only be displayed until your Project Explorer view is changed. Since only Java source files are displayed in Package View, the Show All Files button is disabled.

Note If a directory within your project directory structure does not contain a Java source file, it will not be displayed in Package View. Only directories that contain at least one Java source file are displayed in Package View.


Launch Tab (Project Properties Dialog Box)

The Launch tab allows you to choose a class file, HTML page, or external program to use when your project is run inside Visual J++.

From the Launch tab you can:

  • Choose the class file or HTML page that will be used as a starting point when your project is run from within Visual J++.

  • Determine whether Java applications will run using a console window or the Visual J++ Output window for program output.

  • Start a separate program (instead of Internet Explorer, JVIEW, or WJVIEW) when your project is run from inside Visual J++.

Options

Configuration

This option contains a list from which you can select your build type. This setting is global to all the tabs in this dialog box.

Your choices are:

  • Debug – This is the version of your application that includes information to assist in debugging.

  • Release – This is the version of your application that will be distributed to your users.

  • All Configurations – This option is used to make setting changes global to all build types.

Default Section

This option allows you to choose a class file (which is the compiled output of your Visual J++ project source files) or an HTML page to run, as well as the application it will run inside.

Project File to Run List

This list provides the names of the class files and HTML pages that can be run from within Visual J++. You can select a class file that contains a class with a properly defined main method (such as an application project), a class file that contains a class that extends the java.applet.Applet class (such as an Applet project), or an HTML file.

Program

Displays the program that will host the selected file from your project when it is run. This could be JVIEW (for applications and applets), Microsoft Internet Explorer (for HTML files) or WJVIEW (for Java applications displaying windows). This text box cannot be modified.

Arguments

Lists the arguments that are passed to the program specified in the Program text box. This text box cannot be modified.

Launch as a Console Application

Allows you to determine whether your application will display its output in a standard console window or in the Visual J++ environment. When this option is checked, all output is displayed in a console window. When this option is not checked, the Java program runs in the Visual J++ environment and all output is sent to the Visual J++ Output window. This option is only enabled when a Java class file is selected from the Executing File List. The default value for this option is unchecked.

Custom Section

Allows you to run a completely different executable program when your Java program starts.

Program

The path and name of the executable to be started.

Arguments

The arguments that are passed to the program when it starts.


Compile Tab (Project Properties Dialog Box)

The Compile tab allows you to make changes to the compiler settings.

From the Compile tab you can:

  • Make general compiler settings.

  • Disable Microsoft extensions from being compiled.

  • Set conditional compilation identifiers with which you want to compile.

  • Specify the root directory where class files will be generated.

Options

Configuration

This option contains a list from which you can select your build type. This setting is global to all the tabs in this dialog box.

Your choices are:

  • Debug – This is the version of your application that includes information to assist in debugging.

  • Release – This is the version of your application that will be distributed to your users.

  • All Configurations – This option is used to make setting changes global to all build types.

Warning Level

Use this option to choose warning levels for your project. The levels range from no warning to warning level 4. The higher the level, the more sensitive the compiler will be. The following is a list of the different warning levels and their meaning.

Warning level | Description
None | Turns off all warning messages.
Level 1 | Displays only severe warning messages.
Level 2 | Displays warning messages less severe than Level 1. (Default)
Level 3 | Displays warning messages less severe than Level 2. For example, not initializing a local variable or specifying an invalid compiler setting.
Level 4 | Displays all warning messages.

Disable Microsoft Language Extensions

When selected, this option directs the compiler to disallow Java language extensions defined by Microsoft. Language features such as conditional compilation will be treated as syntax errors if encountered in your source files.

Note Disabling Microsoft language extensions from your projects may not result in syntax errors with comment-based extensions like J/Direct. However, your program will not run correctly.

Generate Debugging Information

When selected, this option directs the compiler to include full debugging information, such as line number references, in the compiled Java class files. Adding debugging information to your compiled files allows you to debug your application from within the Visual J++ environment. Including debugging information in your compiled code may decrease code execution speed and increase the size of your compiled code.

Optimize Compiled Code

When selected, this option informs the compiler to perform a fully optimized compilation of the source files in the project. Selecting this option will allow the compiler to tune your Java class files so they can execute faster.

Recompile Only Changed Files

When selected, this option informs the compiler to only compile files that have been changed. You can use this option to optimize compile time by.

Treat All Warnings As Errors

When selected, this option informs the compiler that all warnings are to be treated as errors. Using this option requires all warnings be eliminated from the source code before compilation can succeed.

Output Directory

A text box that allows you to specify an alternate output directory to use when your project is compiled. You can use this directory to differentiate between the different builds of your project.

Conditional Compilation Symbols

This text box allows you to enter a space, tab, semicolon, or comma-delimited list of strings that represent the conditional identifiers used within any conditional compilation code.

Additional Compiler Options

This text box allows you to pass compiler options, that are not available in this dialog box, to the compiler. Any items entered in this text box are passed as command line settings to the compiler after all other options have been passed to the compiler.


Classpath Tab (Project Properties Dialog Box)

The Classpath tab allows you to specify the location of packages required by your project to run within Visual J++. If your source code requires classes located in packages that are not installed on your system or are not part of your project, this list allows you to define the path to the package. Also displayed in this dialog box is a list of packages that are already installed on your system and are available to your project.

In the Classpath tab you can:

  • View the list of packages that are already installed on your system.

  • Add or remove package paths that are specific to your project.

  • Change the search order of project-specific packages.

Options

Configuration

This option contains a list from which you can select your build type. This setting is global to all the tabs in this dialog box.

Your choices are:

  • Debug – This is the version of your application that includes information to assist in debugging.

  • Release – This is the version of your application that will be distributed to your users.

  • All Configurations – This option is used to make setting changes global to all build types.

Default Path

Displays the current project path. Because the project path is the most frequently accessed path, it is automatically displayed as the top item in the project-specific packages list. The project path is not editable in this display.

Project-Specific

This list displays the location of packages required by your project to run within Visual J++. You may have classes in various locations throughout your local or network path. With this list, you can see at a glance what search paths exist for your project's required class files. You can also add new search paths to the list. The list is displayed in the search order that the VM and compiler use to find classes; therefore, paths located at the top of the list are found first. If you double click an item in the list, the Extend Classpath dialog box is displayed. This dialog box allows you to modify the path entry.

Merge All Project-Specific Classpaths In Solution

When selected, this option will merge all of the project paths in a solution. Use this option if a project path in your solution is needed by another project.

New

Displays the Extend Classpath dialog box for adding a new path to the project's class path entries.

Delete

Deletes the selected path entry from the list.

Up

Moves the selected path up in the search order.

Down

Moves the selected path down in the search order.

Available Packages

Displays a list of the packages that have already been installed on your system. Packages listed here are global to all Java programs and can be used from your project without adding them to the Project Specific list. The Available Packages list is not editable from this display.


COM Classes Tab (Project Properties Dialog Box)

The COM Classes tab allows you to expose classes in your project as Component Object Model (COM) objects.

Note Settings made in this tab are defined for all builds of the project, regardless of the Configuration list setting in this dialog box.

From the COM Classes tab you can:

  • Create classes that can be called from other applications using COM.

  • Create or use external type libraries with your project.

Options

Classes with COM Extensions

This list displays all the Java class definitions in your project that are capable of being exposed through COM. Selecting a check box next to a class in the list marks the class as a COM class. Visual J++ places code at the top of the class definition in the form of a comment tag, when the OK or Apply button for the dialog box is clicked. This code notifies Visual J++ to register the class as a COM object.

Automatically Generate Type Library

When this option is selected, a type library is automatically generated each time you build your project. Visual J++ generates a type library for all the classes that are checked in the Classes with COM Extensions list.

Options

Displays the Type Library Options dialog box for setting options for the automatically created type library.

Use Existing Type Library

This option allows you to specify an existing type library file. If you choose this option and select a valid type library file or a file that contains an embedded type library, such as an OCX, DLL, or EXE file, Visual J++ creates class templates for them in your project.

Select

This option displays the COM Templates dialog box for selecting the pre-existing type library you want to use in your project. The type library may be a stand-alone file, or it could be embedded in a COM executable (such as an OCX, DLL, or EXE file).


Java Exceptions Dialog Box

The Java Exceptions dialog box defines exception handling settings for Java exceptions that occur during debugging sessions.

Options

Exceptions List

This is a tree view list that displays the entire Java exceptions hierarchy. Each exception listed in the tree displays an icon that shows the current breakpoint setting. A red icon indicates that the exception will cause Visual J++ to break on the line of code that caused the exception. A large gray icon signifies that the exception will not cause a break into the debugger if there’s an exception handler; otherwise, a break will occur. A small gray icon signifies that the exception will use its superclass' current setting. The default setting for all exceptions is to not break into the debugger when an exception occurs and a handler is present.

Exception Settings

This group of option buttons is used to set the break status for the currently selected exception from the Exceptions List. The options are:

Break into debugger This displays a message box when the selected exception type occurs. This message box provides the ability to view the code (if available) that caused the exception. A large red icon is displayed when this setting is chosen.

Continue and break only if the exception is not handled If the selected exception occurs, Visual J++ stops only if the exception is not handled by exception handling code. This is the default setting for all exceptions. A large gray icon is displayed when this setting is chosen.

Use setting from superclass Uses the break setting for the currently selected exception's superclass. Depending on the exception's superclass setting, a small red or gray icon is displayed when this setting is chosen.

Find

Displays the Find dialog box that allows you to enter a string of text to search for a specific exception within the Exceptions List.

Find Next

Used with the Find button, this button displays the next exception that contains the text entered in the Find dialog box.

Clear All

Clears all exception handling settings that have been made and returns them to the default settings.


J/Direct Call Builder

J/Direct Call Builder is a graphical tool for automating the process of calling the Win32 API from within Java programs.

With the J/Direct Call Builder you can:

  • View a list of methods, structures, and constants from the Win32 API to add to your project.

  • Choose the target class in which to add the API usage code.

  • Add the code necessary to use a specific API method, structure, or constant to a class in your project.

Options

Source

This dialog box allows you to select the API text file that you wish to use with the J/Direct Call Builder. The default option is the WIN32.TXT file, which allows you to import Win32 API methods, structures, and constants.

Note The J/Direct Call Builder only provides API listings for the GDI32, Kernel32, User32, Shell32, Advapi32, Spoolss and Winmm Win32 API Libraries.

Target

A non-editable text box that displays the class that the J/Direct Call Builder will add code to. The default value for the text box is a class called Win32. If this class does not exist when you select an API to import, you will be prompted to create the class in a Java source file called Win32.java. To choose a different class in which to add your API imports, click the button located next to the Target text box. This displays the Select Class dialog box, which allows you to select a class from your project or the Clipboard. Choosing the Clipboard as the target for class imports allows you to paste the import into any class you choose. Since structures are defined as classes in Java, when a structure is selected from the API Elements list, the structure's class is created as a nested class of the class selected in the Target text box.

API Elements List

This contains a list of the Win32 API elements found in the text file specified in the Source text box. This list can be filtered using the Method, Structs, or Constants check boxes located at the top of the window. You can get help on any Win32 API element by right-clicking on the API element and choosing the Display API Help menu item from the shortcut menu. To add a selected API element to your project you can either select the element in the list and then click the Copy to Target button, or double-click the element in the list. This will add the necessary code to the class file specified in the Target text box. The Find text box located above the list allows you to type a string of text to search for a specific element in the list. Multiple API elements can be selected from the list by holding down the CTRL key and clicking on the list items that you want to add. A display area below the list shows the code that will be added for the currently selected API elements. You can determine the type of API element based on the associated icon. The list below illustrates each icon that can be displayed in the list and its meaning.

Icon | Description
 | Method
 | Constant
 | Struct (Structure)

Methods

When this option is selected, any methods contained in the currently selected API are displayed in the API Elements list. The default value for this option is true.

Structs

When this option is selected, any structures contained in the currently selected API are displayed in the API Elements list. The default value for this option is true.

Constants

When this option is selected, any constants contained in the currently selected API are displayed in the API Elements list. The default value for this option is true.

Copy to Target

This copies the specified API elements to the class specified in the Target text box.


J/Direct Call Builder Options Dialog Box

The J/Direct Call Builder Options dialog box allows you to specify options for the J/Direct Call Builder.

With the J/Direct Call Builder Options dialog box you can:

  • Determine whether the J/Direct Call Builder will display the source after an API import.

  • Enable or disable the addition of security checks for API calls.

Options

Show Target Window When Copy To Target

When this option is selected, the J/Direct Call Builder displays the Text editor with the class that has been selected as the target class for API imports when an API import is added to the target class.

Disable Stack Crawl Security Check

When this option is selected, the J/Direct Call Builder inserts a comment tag before the API import statement that disables the security check normally performed when an API function is called. With this option enabled, your API calls have better performance but could potentially be exposed to others when used in Internet applications.

Note Once added, clearing this option will not remove the disable security check comment in your target class.


COM Wrappers Dialog Box

The COM Wrappers dialog box allows you to create Java source code wrappers in your project for accessing COM components.

A COM wrapper is Java source code that allows you to gain access to a specific COM component on your system. If you have a COM component (such as an ActiveX control) that you wish to use in your project, you can select the registered type library (in the case of a DCOM component) or COM component from the list and Visual J++ will create Java classes to access the COM component or type library.

With the COM Wrappers dialog box you can:

  • Select the components you wish to create a Java source file for from a list of COM components that are registered on your system.

  • Browse your computer for TLB, OLB, OCX, DLL, or EXE files that you wish to create COM wrappers for.

  • View location, language, and version information on COM components highlighted in the Installed COM Components list.

Options

Installed COM Components List

This is a list of all COM components registered on your system. You can select a COM component from the list by clicking the check box next to the name. When the OK button is selected, the environment will create a package, source files, and code for each of the COM classes and interfaces found in the component and adds them to your project. The code that is created allows you to access the COM component from within your Java project.

Browse

Displays a dialog that allows you to browse your computer system for a DLL, EXE, OCX, TLB or OLB file that you wish to access in Java. Use this feature only if the COM component you want to use is not currently registered on your system.

Component Information

Below the Installed COM Components list is a section that displays information for the currently highlighted COM component.

Location The location of the selected COM component on the computer.

Language Displays the name of the human language that the COM component is designed for.

Version Displays the version number of the selected COM component.


COM Templates Dialog Box

The COM Templates dialog box allows you to create Java class templates for registered type libraries and COM components on your system.

A COM template allows you to use Java source code to implement COM components that are described in type libraries and existing COM components. If you have a type library or existing COM component that you wish to implement using Java, you can select a registered type library or COM component from the list and Visual J++ will build the template code in your project. You can then implement each of the methods templates provided and compile to create a COM component.

With the COM Templates dialog box you can:

  • Select the components you wish to create Java class templates for from a list of COM components and type libraries that are registered on your system.

  • Browse your computer for OCX, DLL, EXE, TLB, or OLB files that you wish to create class templates for.

  • View location, language, and version information on COM components and type libraries highlighted in the Installed COM Components list.

Options

Installed COM Components List

This is a list of all COM components and type libraries registered on your system. You can select a COM component or type library from the list by clicking the check box next to the name. When the OK button is selected, the environment creates a package, source files, and class templates for each of the classes found in the COM component or type library and adds them to your project.

Browse

Displays a dialog box that allows you to browse your computer for a DLL, EXE, TLB, OLB, or OCX file that you wish to create Java class templates for. Use this feature only if the COM component or type library you want to use is not currently registered on your system.

Component Information

Below the Installed COM Components list is a section that displays information for the currently highlighted COM component or type library.

Location The location of the selected COM component or type library on the computer.

Language Displays the name of the human language that the COM component or type library is designed for.

Version Displays the version number of the selected COM component or type library.


Type Library Options Dialog Box

The Type Library Options dialog box allows you to change type library settings for the type library that is automatically generated for COM classes in your project.

When you select classes to be registered as COM classes in the COM Classes tab of the Project Properties dialog box, a type library is automatically generated. This dialog box allows you change the settings for the type library file.

Options

File Name

A text box that allows you to specify the name of the type library that is generated. The default is the name of your project.

Library Name

A text box that allows you to specify the name of the library. This name is displayed when a user is importing the type library into their project. The default name for the library is the name of your project.

Description

A text box that allows you to enter a short description for the library. This information is viewable (depending on the tool) when a user imports your type library into their project. The default description is the name of your project.

Help File Name

A text box that allows you to specify the help file that will be used to provide help on members of your COM classes.

Help Context ID

A text box that allows you to specify a help context ID. This ID can be used by your COM classes to select a specific help topic from the help file specified in the Help File Name text box.


The Forms Designer

The Forms Designer allows you to visually design the windows, dialog boxes, and components in your application.

With the Forms Designer you can:

  • Resize the form to the size needed for normal display.

  • Add components to the form.

  • Lock components so that they cannot be moved within the Forms Designer.

  • Double-click on a component or the form to create an event handler for the form's or component's default event.

  • Set properties on the form to change its display position, size, caption buttons, and MDI client state.

  • Align and size components based on the form or other components on the form.

  • Create menus for the form.


Properties Window (Visual J++)

The Properties window allows you to view and modify the properties (design-time only) and events of Java forms and components in your project.

With a Java object selected, you can use the Properties window to:

  • View and modify the properties of forms and WFC components.

  • Create event handlers for forms and components that are on a form.

Views

When the Form Designer is displayed, the Properties window provides two different views, the standard Properties View and Event View. You can switch between these views by selecting either the Properties button or the Events button from the Properties window.

Properties View

Properties View displays all of the properties for the selected form or component. This is the default view for all objects in Visual J++.

Event View

Event View displays all of the events and any event handlers for the specified form or component. You can add an event handler by either double-clicking the event name to create a default handler (the name of the event handler method will be in the nameOfObject_eventName format) or by entering your own event handler name next to the event you wish to handle. Either method will display the Text editor at the location that the event handler is created.


Introduction (Data Form Wizard)

The Data Form Wizard is designed to automatically generate WFC forms that contain individual bound controls and methods used to manage information derived from local or remote data sources. You can use the Data Form Wizard to create single recordset forms to manage the data from a single table, or Master/Detail type forms to manage more complex one-to-many data relationships.

This step of the wizard allows you to choose a profile to retrieve settings from a previous Data Form Wizard session.

Options

Profile Selection

A list that allows you to select a profile. A profile is a file that stores your settings from a previous wizard session. The ellipsis button, located next to the list, allows you to choose a profile other than those provided in the list.


Database Type (Data Form Wizard)

Allows you to select the type of database you want to use as a data source for this form.

Options

Database Formats List

Lists the database formats available to Visual J++. The available database formats are:

  • Access Any version of the Microsoft Access .MDB database.

  • ODBC Any ODBC compliant database driver. You should select this option to connect with any ISAM database (dBase, FoxPro, Paradox) or remote data source (SQL Server, Oracle). Although you can use the Microsoft Access ODBC driver, it is recommended that you select the Access option to gain better performance.


Access Database (Data Form Wizard)

Allows you to select a Microsoft Access database file to use for your data form.

Options

Database Name

Allows you to enter the name and location of the Microsoft Access database file you want to use, or it displays the name of the database file you chose when you used the Browse button.

Browse

Displays an Open dialog box so you can search for the database file you want to use.


Connect Information (Data Form Wizard)

Collects the necessary information to connect to an ODBC data source. This step only appears if you chose Remote (ODBC) for the database type in the Database Type step of the wizard.

Options

DSN (Data Source Name)

Displays a list of DSNs currently installed on your computer to which you can connect. Use the 32-bit ODBC icon in the Control Panel to install new DSNs.

UID (User ID)

Allows you to type the User ID required to connect to this data source. If the data source does not require a User ID, leave this blank.

PWD (Password)

Allows you to type the password required to connect to the data source. If the data source does not require a password, leave this blank.

Database

Allows you to type the name of the database to which you want to connect.

Driver

Displays a list of drivers currently available on your computer that you can use to create a connection to a Remote data source. This option is not available if you select a DSN.

Server

Allows you to type the name of the server where the database resides. This option is not available if you select a DSN.


Form Type (Data Form Wizard)

Allows you to select the name and type of form you want to create.

Options

Form Name

Allows you to specify the name of the form. This name is also used to name the form's source file. The name of the data source (without its extension) is used as the default name.

Form Layout

Single record Specifies a form that displays one record at a time. This is the default.

Grid (Datasheet) Specifies a form that displays the selected fields in the Grid (Datasheet) format using the data bound grid control.

Master/Detail Specifies a form that displays a Master record source and a Detail record source linked together. The Master record source is in single record format and the Detail record source is in a Grid (Datasheet) format. When data in a Master record source row changes, the data in the Detail record source automatically changes based on the link between the two.

Controls

When this option is selected, ADO DataSource and DataBinder controls are placed on the form. These controls are used to set the data source connection and perform data binding at design time. If the selected form type is Grid (Datasheet), a DataBinder control will not be placed on the form. This option is selected by default.

Code

When this option is selected, all data source connection and binding of controls on the form is done through code. Use this option if you want to have fine tune control of how data binding is performed in the form.


Record Source (Data Form Wizard)

Allows you to choose the record source and fields within the record source to place on the form.

Options

Record Source

Lists available record sources in the database to choose as the source of data for your form.

Available Fields

Lists the available fields in the selected record source.

Selected Fields

Lists the fields to include in your form.

Selection and Order Buttons

Buttons are provided to move items between the Selected Fields list and the Available Fields list as well to change the order of the fields on the form. The following shows each button and its meaning:

Button | Description
 | Moves the selected field in the Available Fields list to the Selected Fields list.
 | Moves all of the fields in the Available Fields list to the Selected Fields list.
 | Moves the selected field in the Selected Fields list to the Available Fields list.
 | Moves all of the fields in the Selected Fields list to the Available Fields list.
 | Changes the order of the fields on your form. Each time you click the button, the selected field in the Selected Fields list moves up one position.
 | Changes the order of the fields on your form. Each time you click the button, the selected field in the Selected Fields list moves down one position.

Column to Sort By

Specifies the field you want to use for sorting. This can be any field in the selected record source and is not limited to the fields selected for display.


Control Selection (Data Form Wizard)

Allows you to choose the controls you want to appear on the form and enables the wizard to create the associated code for each control.

Options

Add Button

When selected, this option places an Add button on the form with the associated code to add new records to the database.

Delete Button

When selected, this option places a Delete button on the form with the associated code to delete records from the database.

Refresh Button

When selected, this option places a Refresh button on the form with the associated code to refresh data from the database.

Update Button

When checked places an Update button on the form with the associated code to update data from the database.

Close Button

When selected, this option places a Close button with the associated code to close your form.

Show Data Navigator

When selected, this option places a Data Navigator control on your form for navigating the records of the form's recordset.


Summary (Data Form Wizard)

Allows you to specify a profile to save your wizard settings for reuse when using the wizard.

Options

Profile Name

A list that allows you to specify an existing profile to store your wizard settings. A profile file stores the settings of the wizard so they can be reselected the next time you use the Data Form wizard. A button located next to the list displays a dialog box in which you can create a new profile name and specify its location. The default setting is "(None)" which does not save your settings in a profile.

View Report

This button displays a dialog box that allows you to review the settings that you made while running the Data Form wizard. You can save the report as an HTML file to your hard disk for reading later.


Custom Tab (Project Properties Dialog Box)

The Custom Tab allows you to define commands that will be applied before and after building your project. When you build, Visual J++ creates a batch file that contains the commands specified in this dialog box. Visual J++ then executes the pre-build rules, if any, before building your project. After your project has successfully been built, the post-build rules are executed, if any are defined. All output from the pre- and post-build commands is displayed in the Visual J++ Output Window.

Options

Configuration

This option contains a list from which you can select your build type. This setting is global to all the tabs in this dialog box.

Your choices are:

  • Debug – This is the version of your application that includes information to assist in debugging.

  • Release – This is the version of your application that will be distributed to your users.

  • All Configurations – This option is used to make setting changes global to all build types.

Pre-Build Commands

A multi-line text box that defines the commands to execute before building the currently specified project. The pre-build commands can be any batch command or program you wish to execute. Clearing the text box prevents any pre-build commands from occurring.

Post-Build Commands

A multi-line text box that defines the commands to execute after building the currently specified project. The post-build commands can be any batch command or program you wish to execute. Clearing the text box removes any post-build commands.


WFC Controls Tab (Customize Toolbox Dialog Box)

Allows you to add or remove WFC components from the toolbox.

With the WFC Tab you can:

  • View a list of the installed WFC components on your system.

  • Add or remove WFC components from the toolbox.

Options

Installed Components List

A check box list of the WFC components currently installed on your system. A check mark in the check box next to the component name indicates that the component is currently displayed in your toolbox. The list also displays the package where the component is located.

Note To have a component displayed in the list of installed components, the path to the component must be defined in either the Classpath or the Java Package Manager.


Introduction (Application Wizard)

The Application Wizard provides a step-by-step way to create a Windows application. Various features can be selected during the course of the wizard, which can add additional capabilities to the application the wizard generates. The wizard generates all code and forms needed to produce a working "Notepad" style application. Once the wizard is complete, you can modify the application to fit the needs of your project. When the wizard has completed its process, a report can be displayed that provides helpful suggestions on features you can add or change in the wizard's output project.

Options

Profile Selection

A list that allows you to select a profile. A profile is a file that stores your settings from a previous wizard session. A button is provided next to the list to choose a profile file from your computer to use instead of those listed in the list.


Application Type (Application Wizard)

Allows you to determine the type of application the wizard will generate.

Options

Form Based Application

When selected, the Application wizard generates a form-based application. The application developed by the wizard is a simple "Notepad" type application.

Form Based Application with Data

When selected, the Application Wizard starts the Data Form wizard to step you through the process of creating a single form application based on a database.

Note This step of the Application wizard is only available in the Visual J++ Professional edition and the Enterprise edition of Visual Studio.


Application Features (Application Wizard)

Allows you to specify features to add to your application's form.

Options

Features List

A list of features that you can add to the application generated by the wizard. A check box next to each feature in the list indicates if the wizard will add it to your form. The following is a list of available features to add to your form:

Feature | Description
Menu | When selected, the wizard adds a pre-defined menu to the form it generates.
Edit | When selected, the wizard adds an edit control to the form that fills the contents of the window. By selecting the edit box option the wizard uses the edit control to create a "Notepad" style application.
Toolbar | When selected, the wizard adds a toolbar and pre-defined buttons to the form it generates.
Status Bar | When selected, the wizard adds a status bar to the form it generates.


Commenting Style (Application Wizard)

Allows you to specify the how much and what type of comments you want the wizard to generate for your application.

Options

Doc Comment

When this option is selected, the wizard adds Javadoc comments to all classes and their members. Javadoc comments make documenting your code easier. The comments generated by the wizard provide useful information on the code that the Application wizard generates.

TODO Comments

When this option is selected, the wizard adds TODO comments in sections of the code that the wizard generates which can be modified or where code should be added to enhance the application. You can view TODO comments in the Task List window.

Sample Functionality Comments

When this option is selected, the wizard adds comments for any sample functionality code generated by the wizard. Sample functionality comments provide information on what the code added by the wizard is intended to do, and it can assist you in determining what code was automatically generated for your application.


Summary (Application Wizard)

Allows you to specify a profile to save your wizard settings for reuse when using the wizard.

Options

Profile Name

A list that allows you to specify an existing profile to store your wizard settings. A profile file stores the settings of the wizard so they can be reselected the next time you use the Application wizard. A button located next to the list displays a dialog box where you can create a new profile name and specify its location. The default setting is "(None)" which does not save your settings in a profile.

View Report

This button displays a dialog box that allows you to review a report that contains the settings you made while running the Application wizard. The report also displays suggestions for things to consider or do with the application generated by the wizard. You can save the report as an HTML file to your hard disk for reading later.


WFC (Form Designers - Options Dialog Box)

Provides options for configuring the Visual J++ Forms Designer.

With the WFC section of the Form options you can:

  • Determine if a grid is displayed on the Forms Designer to aid in placing controls.

  • Configure the height and width of grid cells on the Forms Designer.

  • Determine if controls will be automatically aligned with the grid.

Options

Show Grid

When selected, the Forms Designer displays a grid. This grid allows you to position and align controls easier. This option is selected by default.

Vertical Spacing

A text box that allows you to define the width, in pixels, between each column in the Forms Designer grid. Assigning a smaller number assigns a smaller distance between grid columns. This text box is disabled if the Show Grid option is not selected.

Horizontal Spacing

A text box that allows you to define the height, in pixels, between each row in the Forms Designer grid. Assigning a smaller number assigns a smaller distance between grid rows. This text box is disabled if the Show Grid option is not selected.

Snap To Grid

When selected, controls added to a form or moved on a form are automatically aligned to the rows and columns of the Forms Designer's grid. You can finely govern where controls are placed on a form, after they have been aligned on the grid, by changing the control's positioning properties. This option is not available if the Show Grid option is not selected. This option is selected by default.


Java Format (Text Editor - Options Dialog Box)

Provides options for Java source code formatting.

With the Java Format section of the Text editor options you can:

  • Determine if indenting will occur in the editor.

  • Specify the format style for code braces.

  • Specify how various code elements will be indented and aligned.

Options

Indenting

A group of options for determining the type of indentation support for the Text editor. The following is a list of the options available for indentation:

Indentation mode | Description
None | The Text editor does not automatically add indentation while you are entering code. Text goes to the beginning of the line when a return is entered.
Block | The text editor adds indentation but keeps the code on the same indentation level until you change it.
Smart | This is the default setting. The Text editor adds indentation and uses the context of the indentation to determine the level automatically.

Separate Smart Indent Actions In Undo List

When this option is selected, Undo commands (accessed by clicking the Undo menu item from the Edit menu or by pressing CTRL+Z on the keyboard) separates the automatic indentation caused by Smart indenting from other keystrokes. This allows you to undo Smart indentation actions without undoing the command that caused the indentation to occur. If the Smart indentation option is not selected, this option is disabled.

Indent Braces With Contained Code

When this option is selected, a brace is indented to be in-line with code that follows the brace. This option is not selected by default.

Format Open Brace

When this option is selected, open brace entries are formatted for you. A list is provided next to this option to allow you to select the style of open brace formatting. The following contains a list of the options for open brace formatting:

Open brace format | Description
On separate line | When this format is selected, an open brace is automatically positioned on a separate line from the method or code block that the open brace belongs to.
At end of line | When this format is selected, an open brace is automatically positioned on the same line as the method or code block that the open brace belongs to.

This option is not selected by default.

Indent Case Labels

When this option is selected, case labels are indented within the case's switch block. This option is not selected by default.

Align Operands In Multi-Line Expressions

When this option is selected, the operands in a multi-line expression are aligned one below the other. For example:

      int total += var1 + var2
                        + var3
                        + var4;

When not selected, continuation lines are indented by one additional tab stop. This option is selected by default.

Align Parameters

When this option is selected, the parameters in a multi-line method declaration or call are aligned with the first parameter in each line of the declaration or call. For example:

      public native void method1 (String arg1, String arg2
                                  String arg3,
                                  String arg4);

When not selected, continuation lines are indented by one additional tab stop. This option is selected by default


Java Tasks (Text Editor - Options Dialog Box)

Provides settings for determining how the Task List works with your code.

With the Java Tasks section of the Text editor options you can:

  • Determine if comment tasks will appear in the Task List.

  • Determine if Visual J++ will perform syntax checking of your code while you are typing.

  • Determine if code errors will be reported in both the Task List and the Text editor.

Options

Detect Comment Tasks

When this option is selected, the Task List displays comment tasks entered in code. You can add or modify the strings that you want to be detected as comment tasks in the Environment section of the Options dialog box. This option is selected by default.

Check Syntax As You Type

When this option is selected, Visual J++ checks the syntax of your code as you enter it in the Text editor. Syntax errors detected are displayed in the Task List. This option is selected by default.

Include Statement-Level Errors

When this option is selected, Visual J++ performs a more detailed check for syntax errors while you are typing. This option is not available if the Check Syntax As You Type option is not selected. This option is selected by default.

Underline Syntax Errors As You Type

When this option is selected, Visual J++ displays a red "squiggly" line under any code that contains a syntax error. This option is not available if the Check Syntax As You Type option is not selected. This option is selected by default.

Underline Java Compilation Errors

When this option is selected, the Visual J++ compiler displays a blue "squiggly" line under any code that produced an error during compilation. Descriptions of any errors that are found during compilation are displayed in the Task List. This option is selected by default.


Select Class Dialog Box

The Select Class dialog box allows you to select a class from the classes in your project.

With the Select Class dialog box you can:

  • Select a class from the tree that you wish to use.

  • View your projects in either Class View or Project View.

Options

Project View

This option allows you to view your project's classes in a way similar to the Project Explorer. Project View displays the projects and class files that make up your project. You can select a class file and any of the classes that are defined inside the class file. To select a class you can either double-click the name of the class or click the class name and then click the OK button.

Class View

This option allows you to view your project's classes in a way similar to the Class Outline. Class View displays a simple list of each available class in the currently selected project. To select a class you can either double-click the name of the class or click the class name and then click the OK button.

Note When the Select Class dialog box is displayed from the J/Direct Call Builder, two additional objects are available for selection. These objects are the Windows Clipboard and a predefined class called Win32.


EXE/DLL Options Tab (Advanced Properties Dialog Box)

Defines the options for COM DLL and Windows EXE packages.

With the EXE/DLL Options Tab of the Advanced Properties dialog box you can:

  • Specify the version of the COM DLL or Windows EXE package you are creating.

  • Specify the base DLL address for COM DLLs.

  • Enter product, company, and file information that can be viewed by a user.

Options

Version Number

Allows you to define the version information for the Windows EXE or COM DLL you are creating. Three text boxes are provided for defining the Major, Minor, and Revision numbers of the version. This information can be viewed from within Windows by the user to determine the version of the Windows EXE or COM DLL they are currently running.

Preview

A preview of what the version information will look like based on the numbers entered in the Major, Minor, and Revision text boxes.

DLL Base Address

A text box that allows you to specify the base memory address where the COM DLL will be loaded. This text box is only displayed when you are creating a COM DLL package. Specifying a base address for your COM DLL is not required; however, by specifying a base address, you can avoid using the same memory location as other DLL's in memory. This will cause the load time of your COM DLL to be faster.

Type

A list box that allows you to select the type of information to add or modify for the Windows EXE or COM DLL you are creating. The Value text box allows you to define a string value for each selected item in the list.

Value

A multi-line text box that allows you to specify a string value for the currently selected information type in the Type list box.


Packaging Options (Application Wizard)

Defines the type of package to create for the application you are creating with the wizard.

Options

Class Files

When this option is selected, the Application wizard will not put the project into a package file of any type. Use this option if you want to use a method other than packaging for distributing your application. This option is selected by default.

EXE File

When this option is selected, an EXE file will be created when your project is compiled and built. Use this option if you want to create a file that a user can use to run your application.

Cabinet File

When this option is selected, a cabinet file (CAB) will be created when your project is compiled and built. A CAB file is a compressed file that contains all of the important information for your project. Use this option if you plan to distribute your project through the Internet.

Deploy to (URL)

When this option is selected, you can define a URL to deploy your application to. The text box located below this option allows you to specify a URL to deploy your application to.


Master Record Source (Data Form Wizard)

Allows you to choose the record source and fields within the record source to use for the master section of the form.

Options

Record Source

Lists available record sources in the database you chose.

Available Fields

Lists the available fields in the selected record source.

Selected Fields

Lists the fields to include in your form.

Selection and Order Buttons

Buttons are provided to move items between the Selected Fields list and the Available Fields list, as well to change the order of the fields on the form. The following shows each button and its meaning:

Button | Description
 | Moves the selected field in the Available Fields list to the Selected Fields list.
 | Moves all of the fields in the Available Fields list to the Selected Fields list.
 | Moves the selected field in the Selected Fields list to the Available Fields list.
 | Moves all of the fields in the Selected Fields list to the Available Fields list.
 | Changes the order of the fields on your form. Each time you click the button, the selected field in the Selected Fields list moves up one position.
 | Changes the order of the fields on your form. Each time you click the button, the selected field in the Selected Fields list moves down one position.

Column to Sort By

Specifies the field you want to use for sorting. This can be any field in the selected record source and is not limited to the fields selected for display.


Detail Record Source (Data Form Wizard)

Allows you to choose the record source and fields within the record source to display in the grid used for the detail section of the form.

Options

Record Source

Lists available record sources in the database you chose.

Available Fields

Lists the available fields in the selected record source.

Selected Fields

Lists the fields to add as columns in the grid used to display the details information.

Selection and Order Buttons

Buttons are provided to move items between the Selected Fields list and the Available Fields list, as well to change the order of the fields in the grid. The following shows each button and its meaning:

Button | Description
 | Moves the selected field in the Available Fields list to the Selected Fields list.
 | Moves all of the fields in the Available Fields list to the Selected Fields list.
 | Moves the selected field in the Selected Fields list to the Available Fields list.
 | Moves all of the fields in the Selected Fields list to the Available Fields list.
 | Changes the order of the fields in the grid. Each time you click the button, the selected field in the Selected Fields list moves up one position.
 | Changes the order of the fields in the grid. Each time you click the button, the selected field in the Selected Fields list moves down one position.

Column to Sort By

Specifies the field you want to use for sorting. This can be any field in the selected record source and is not limited to the fields selected for display.


Record Source Relation (Data Form Wizard)

Allows you to create a one-to-many join between the Master and Detail record sources This step only appears if you chose the Master/Detail type of data form.

Options

Master

Lists all available fields from the record source you specified in the Master Record Source step. Clicking a field highlights it and registers it as the linking field for this record source.

Detail

Lists all available fields from the record source you specified in the Detail Record Source step. Clicking the same field in this list highlights it and registers it as the linking field for the second record.


Applets Tab (Customize Toolbox Dialog Box)

Displays a list of all of the applets that are found on the Classpath or are registered in the Java Package Manager (JPM) on your machine and are available to add to your Toolbox. Applets that are part of your compiled solution appear and can be added to the Toolbox. Applets that belong to projects in a solution are removed when you close the solution and are re-added when you open the solution. The applets that have a check mark to the left of their names are already added to the Toolbox.

Note To use these options, you must have both Microsoft Visual J++ and Microsoft Visual InterDev installed.

You can:

  • Add an applet to the Toolbox, by selecting it in the Name and Package list and clicking the check box to the left of the control.

  • Remove an applet from the Toolbox by clearing the check box.

  • Group your list of applets by name and package by clicking the appropriate column heading.

Options

Name and Package List

Displays the available applets: their names and the package to which it belongs.

Description

Displays the current package in which the applet is located or a custom description that is defined by the applet.

Reset

Restores the Toolbox to its default state and refreshes the currently open tab. The default applets appear with a check in the check box to the left of them.


Samples

Visual J++ Samples

Visual J++ includes a number of samples that you can examine to learn more about the new technologies available in this product. Demonstrated technologies include:

  • Windows Foundation Classes (WFC)

  • Visual J++ Extensibility

  • Dynamic HTML (DHTML)

  • ActiveX Data Objects (ADO)

  • Microsoft Transaction Server (MTS)

  • VBScript and JScript

  • J/Direct

All Visual J++ samples are contained in a single, self-extracting executable file. To extract these samples:

  1. Insert the Microsoft Developer Network Library CD 1 into your CD-ROM drive. Navigate to the msdn98\98vs\<LCID>\samples\vj98 directory.

    -or-

    If you installed Visual J++ Samples through a custom or full MSDN setup, navigate to the Program Files\Microsoft Visual Studio\msdn98\98vs\<LCID>\samples\vj98 directory.

  2. Double-click vj6sampl.exe to extract and install the samples.

Once the installation process is complete, review the start.htm page that is copied into the root folder of the destination you selected. This page provides complete overviews and links to each sample.


Topic Not Found

No matching topic was found. Some possible reasons and remedies are as follows:

  • The file (.chm) that contains the destination topic is not in the expected location.

    Remedy: Rerun the MSDN Library Setup.

  • The file (.chm) that contains the current topic or destination topic is out-of-date and the link is no longer valid.

    Remedy: Install the latest version of the MSDN Library.

  • The MSDN Library CD is not in the CD-ROM drive.

    Remedy: Insert the MSDN Library CD into the CD-ROM drive.