aspose file tools*
The moose likes Beginning Java and the fly likes Packages.myClass is not a constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Packages.myClass is not a constructor" Watch "Packages.myClass is not a constructor" New topic
Author

Packages.myClass is not a constructor

Raynmune Corsan
Greenhorn

Joined: Nov 04, 2005
Posts: 7
hello.
my class is:

public class Direc {
int x;
int y;
Direc(int x, int y){
this.x=x;
this.y=y;
}
Direc(){
}
}

and when i do this in my .jsp:

var direc = new Packages.Direc();

sends me the error:

Packages.Direct is not a constructor.

both, the class and the .jsp are in the same PATH.
plaese help me.


language.Java = language.C*(mechanics.Relativistic/mechanics.Classical)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61603
    
  67

Moved to Java in General (beginner) as this is not a question on Ant.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61603
    
  67

You need to make your constructors public or they will not be able to be referenced outside of the package within which the class is defined.
Raynmune Corsan
Greenhorn

Joined: Nov 04, 2005
Posts: 7
Dear Bear Bibeault: thank you. My problem persists.
this is my situation.

every file has the pertinent read permissions
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61603
    
  67

There aren't may rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
Raynmune Corsan
Greenhorn

Joined: Nov 04, 2005
Posts: 7
My name is Raynmune and my last name is the Lord. Please dont hate me for that
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18880
    
    8

Is your class called "Direc" (as in your post) or is it called "Direct" (as in the error message you posted)? And is it actually declared to be in the package "Packages"? I don't see that in your code.
weiqiang wang
Greenhorn

Joined: Oct 23, 2005
Posts: 1
put your class in right directory like WEB-INF/classes/packageName/ClassName

and use import statement in your .jsp file like this.
<%@page import="packageName.ClassName"%>

and you can user this class like this .
ClassName cn = new ClassName();


this is a funny day!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Packages.myClass is not a constructor