an API like thing

how if I am useing jdk1.1.8 on UNIX do I
make a program I make to be imported?

Say I have a program writen, witch takes
3 pices of data in, goes and dos its thing
and returns a result to the calling program

so in a program I would only need to say

import my.file.*
result = myfile(a, 10, go);

what would I need to be defineing the progema
that dos all the work? what would this look like in code?

Thaks for any help
Who is Participating?
Umm, I'm really confused about what you want, but here is how you write a class to belong to a package:

------ -------

package com.mypackage.calculations;

public class Calc{

  public static int calculate(int x, int y){
    return 2*x+y;


---------- End ---------

The file must be in a com\mypackage\calculations directory and you must compile it from the directory which the com directory is in with "javac com\mypackage\calculations\"

thedogeaterAuthor Commented:
I am sorry to comfuse but I too learn english :+)
So if I make the Calc class as you say
I will call it by

import com.mypackage.calculations.*;

calculate(1, 10);

kind of thing ye. so com.mypackage.calcualtios
must alos be in my CLASSPATH yes?

Thanks for the help
1. You will have to call it with Calc.calculate(1,10)... The calculate method is a static class method. If you define it non-static you will have to first instantiate the Calc class:
Calc myCalculator = new Calc();
int result = myCalculator.calculate(1,10);

2. You will need to put the directory in which the com directory is in in your CLASSPATH...
Or youneed to 'extends' the Calc class, so your new class will inherit the methods in Calc.
thedogeaterAuthor Commented:
thank you for the helping I was not getting it working
without you help
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.