Solved

java import class file

Posted on 2009-04-03
5
821 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DO we need Java installed on a Windows PC and WHY ? 13 95
Error with Java/Cache JDBC Classpath 2 30
JavaScript/Java - Changing an image background color 4 54
print map entry 34 54
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

919 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now