• Post Reply Bookmark Topic Watch Topic
  • New Topic

Various Questions  RSS feed

 
Jesse Walker
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some questions I need some help with:

1. When a what to call another class I created I get an unknow class def even when the class is declared as public.

2. If you want to declare your events in another class and then call it, what is the procedure for it. Do you call it inside of the ActionPerformed(or whatever Listeners method you need to use?)

3. How do you input variables into a class that doesnt have any agruments or the arguments are of another type? like in an event method where the type is a type of event but I want to use an int in some calculation, even when the variable is declared in the class as public and the class too

4. When method do you call to get the selection from a combo box?

5. I need help with classpath, I have gone under system properties and edited it, tried to set it in dos, and if the java or class file is not in the current directory then it gives me a error read or a class def not found. I have tried to switch directories to the one they are in and nothing, because javac is not in that directory so how can I complie it. Classpath has given me a headache, please someone help.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if this works for you ...

1. Create a directory structure like:

Package names match the directory structure. So Name1 must have the line "package com.yourName.package1" and Name4 must have "package com.myname.package2".

Code in Name1 can do new Name2() or new Name3() and call methods in Name2 or Name3 in the same package with no further effort.

If Name1 wants to reference a class in another package, you'll have to import that package. So to do new Name4() it must have the line "import com.yourName.package2.*" or "import com.yourName.package2.Name4".

2. Add the JDK bin directory to your command window path.

3. Change directory to src

4. Try javac -d ..\bin com\yourName\package1\Name1

The compiler will find the file Name1 by the directory path and find that its package statement matches it's directory path. If Name1 imports Name4 the compiler will start from the current directory and find package2 and Name4.

If you import from other packages that are not in the same directory tree you'll have to add to classpath. See if you can make something work with two classes in different packages before we go into that. Lemme know if it works!
 
Jesse Walker
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got the different directory issue settled, thanks your advance of ading the jdk bin directory to the command path worked thank you. But I still am having a problem of calling another class that I made, they were in the same directory, in the same package, and both declared public, along with every method, constructor in the class. and I still got an unknown error. What am I doing wrong?
Thanks
Jess
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!