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

x
?
Solved

java import class file

Posted on 2009-04-03
5
Medium Priority
?
870 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
[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
  • 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 1500 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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…
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

636 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