executing functions from a package file
I have a package setup, and one of the files in the package is commands.java. I've compiled this file successfully. Inside of it I have function that returns a value. Is there a way to call this fuction from a different file that includes this package? I've tried and I can't seem to get it to work.
[309 byte] By [
dazmana] at [2007-10-3 0:39:40]

Yes, there is a way, although no file ever "includes" a package in Java.Not having seen what you did and not having an explanation of what "doesn't work" means, I can't offer any advice other than to tell you to google for something like java package tutorial.
jverda at 2007-7-14 17:33:45 >

This doesn't appear to have anything to do with packages whatsoever but more to do with when you call static vs nonstatic methods.
If a method is static you can call it directly on the class.
If a method is non static you must call it on an instance.
Importing a package does not mean that you can call methods randomly without any context. So no matter if the method is static or not you still have to invoke the method on a class or object as appropriate.
Revised main class
import java.io.*;
import includes.*;
class test
{
public static void main(String args[]);
{
commands commandsObject = new commands();
commandsObject.dothis();
}
}
You really might want to go through the online tutorials available on this site starting with http://java.sun.com/docs/books/tutorial/java/concepts/index.html
And it's good to follow some basic conventions as well. Class names should start with CAPITAL letters. ie. Commands and Test