wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes trying to call a object from a different class. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "trying to call a object from a different class." Watch "trying to call a object from a different class." New topic
Author

trying to call a object from a different class.

Joey Brown
Greenhorn

Joined: Jul 09, 2009
Posts: 11


comes up and says package installfin does not exist???
Joey Brown
Greenhorn

Joined: Jul 09, 2009
Posts: 11
questions my package and main class are both called setup would this be a problem?
Eduardo Bueno
Ranch Hand

Joined: Jun 04, 2009
Posts: 155
You're trying to call a method from nowhere. must be inside a method body.
Joey Brown
Greenhorn

Joined: Jul 09, 2009
Posts: 11
still not able to get this to work.
This is the code that I have inside of extractjboss class


this is the code I have in setup class



This is the error I get when I build:

extractjboss.java:275: cannot find symbol
symbol : method finish(java.lang.String)
location: class setup.extractjboss.setup
installfin.finish(curDir);
1 error
BUILD FAILED (total time: 0 seconds)

Eduardo Bueno wrote:You're trying to call a method from nowhere. must be inside a method body.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18133
    
  39

extractjboss.java:275: cannot find symbol
symbol : method finish(java.lang.String)
location: class setup.extractjboss.setup
installfin.finish(curDir);
1 error
BUILD FAILED (total time: 0 seconds)


You have to show us more code... from the error message, it looks like you are playing with inner classes, or something like that....

Henry

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Joey Brown
Greenhorn

Joined: Jul 09, 2009
Posts: 11
This is all my code from jbossextract class



and this is the top part of my code for class setup

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18133
    
  39


You do know that you have two setup classes right? One in the setup package. The other the inner class of the extractjboss class.

So, when the inner class instantiates an setup object, it instantiates one of the inner class type. This inner setup class doesn't have a finish() method. The other setup class does.

Henry
Joey Brown
Greenhorn

Joined: Jul 09, 2009
Posts: 11
Henry Wong wrote:
You do know that you have two setup classes right? One in the setup package. The other the inner class of the extractjboss class.

So, when the inner class instantiates an setup object, it instantiates one of the inner class type. This inner setup class doesn't have a finish() method. The other setup class does.

Henry


No I didn't but now I do... I still cant get this to work.

takes this for example

public class extractjboss implements Runnable {

I can change this to public class extractjboss extends install implements Runnable {

install is another class I have in the same package and it works fine... no errors.

but if I change it to public class extractjboss extends setup implements Runnable {

I get error can not find symbol constructor setup

The only difference I can find is that setup has all the code for my GUI.

I'm very new to java & I'm trying to learn...
Joey Brown
Greenhorn

Joined: Jul 09, 2009
Posts: 11
For some reason this code in the class I'm trying to call is giving me the error.


If I change it to this


The error "cannot find symbol
symbol : constructor Setupnew12()
location: class setup.Setupnew12
Setupnew12 newset = new Setupnew12();"

goes away but I get a different error
call to super must be first statement in constructor
super(parent, modal);
cannot find symbol
symbol : constructor Setupnew12(javax.swing.JFrame,boolean)
location: class setup.Setupnew12
new Setupnew12(new javax.swing.JFrame(), true).setVisible(true);

I love java!!!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36555
    
  16
You are not allowed a return type from a constructor. If you try to put a return type on a constructor, the compiler will convert it to a method which happens to look like a constructor.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: trying to call a object from a different class.
 
Similar Threads
setUp and tearDown
Deciding according the Class type of an object
Reference Specific Line in Text File
The value for the useBean class attribute user.userData is invalid.
setUp and teardown not working