• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 871
  • Last Modified:

java import class file

Hi as per my previous question i am new to java . (1) i have a java app [ getnewkey.jar] , this app request user to input a key [eg AUIL01-1] . (2) i have a java class [key.class ]this generates a new key based on the last key. (3) i Want the java app to call the java class file once the user enters the key in the java app . The java class generates a new key i want to return this to the java app and display ( eg: 'New Key ... BUOPQ
0
skywaker
Asked:
skywaker
  • 3
  • 2
1 Solution
 
basav_comCommented:
declare the main class in the MANIFEST file of the .jar file and call the required classes from the main.
0
 
skywakerAuthor Commented:
how do i do this i am useing netbeans
0
 
skywakerAuthor Commented:
ps the class file is compiled i need to pass the variable key to this file and this would return a new key
0
 
basav_comCommented:
Check this for how to create the .jar file Netbeans.
http://www.fsl.cs.sunysb.edu/~dquigley/cse219/index.php?it=netbeans&tt=jar&pf=y
0
 
basav_comCommented:
(1) i have a java app [ getnewkey.jar] , this app request user to input a key [eg AUIL01-1]    ---->  Consider you have the class 'MainFile.java', declare this 'MainFile' in the MANIFEST file. So watever you give to the .jar file will goto the main method of this class in the args[].

(2) i have a java class [key.class ]this generates a new key based on the last key.   ---> Declare one public method (say generateKey) which takes the input key and returns a new output key as type String.

 (3) i Want the java app to call the java class file once the user enters the key in the java app . The java class generates a new key i want to return this to the java app and display ( eg: 'New Key ... BUOPQ   ----> Now from the MainFile.java main method, instantiate this key.class and call the generateKey method.

Eg. public class MainFile{
  public static void main(String args[]){
    String inputKey = args[0];
     key mykey = new key();
    String outputKey = mykey.generateKey(inputKey);
System.out.println(outputKey);
   
 }

}
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now