Solved

java import class file

Posted on 2009-04-03
5
832 Views
Last Modified: 2012-05-06
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
Comment
Question by:skywaker
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:basav_com
ID: 24063541
declare the main class in the MANIFEST file of the .jar file and call the required classes from the main.
0
 

Author Comment

by:skywaker
ID: 24063572
how do i do this i am useing netbeans
0
 

Author Comment

by:skywaker
ID: 24063579
ps the class file is compiled i need to pass the variable key to this file and this would return a new key
0
 
LVL 12

Expert Comment

by:basav_com
ID: 24063636
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
 
LVL 12

Accepted Solution

by:
basav_com earned 500 total points
ID: 24063728
(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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 107
split string containing \r\n in Java 46 44
how to add new optional parameter to JSP 1 41
CSV file parsing thru Java 13 31
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

778 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