Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

an API like thing

Posted on 2000-05-12
5
Medium Priority
?
168 Views
Last Modified: 2010-04-01
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
0
Comment
Question by:thedogeater
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
Sasha_Mapa earned 800 total points
ID: 2805938
Umm, I'm really confused about what you want, but here is how you write a class to belong to a package:

------ Calc.java -------

package com.mypackage.calculations;

public class Calc{

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

}

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

The Calc.java 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\Calc.java"


0
 

Author Comment

by:thedogeater
ID: 2806760
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
0
 
LVL 7

Expert Comment

by:Sasha_Mapa
ID: 2806871
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...
0
 

Expert Comment

by:prl
ID: 2807006
Or youneed to 'extends' the Calc class, so your new class will inherit the methods in Calc.
0
 

Author Comment

by:thedogeater
ID: 2807194
thank you for the helping I was not getting it working
without you help
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question