kvarnerexpress
Jan 12 2006, 11:05 PM
from an API and outputs the result to the API (like someAPI.submitResult(myResult), which checks the results against the sample values. The idea is that the student is able to click a browse button and locate their .java or .class file, which the GUI then launches. So my question is if I can launch this class as part of the GUI process so that the API actually is actually part of the GUI process. It's a bit backwards really - like launching the API first and then adding in the component that uses the API during runtime. But there is an advantage of doing it this way instead of having the GUI get the question and then the students class being launched on its own with an API separate from the GUI process. If they were two separate processes I'd have to make the student identify what question is being answered, their student ID and password, etc with inputs to the API in their actual code, then they would have to send the submit function call at the end. And the API process would have to include the checking functions and input the data to the database, then the user would have to manually ask GUI to retrieve the results. If I can make it all part of one process the data sharing makes things much more straight forward for the student. Thanks for your help.
Reply
kvkv
Jan 29 2006, 06:19 PM
If i understood correctly, you want to launch a UI (swing probably), allow user to select a class, then call an api of the selected class. It is possible. I am assuming the class selected is in classpath. You need to use java reflection. Here is an example I copied from sun reference docs CODE import java.lang.reflect.*;
class SampleInvoke {
public static void main(String[] args) { String firstWord = "Hello "; String secondWord = "everybody."; String bothWords = append(firstWord, secondWord); System.out.println(bothWords); }
public static String append(String firstWord, String secondWord) { String result = null; Class c = String.class; Class[] parameterTypes = new Class[] {String.class}; Method concatMethod; Object[] arguments = new Object[] {secondWord}; try { concatMethod = c.getMethod("concat", parameterTypes); result = (String) concatMethod.invoke(firstWord, arguments); } catch (NoSuchMethodException e) { System.out.println(e); } catch (IllegalAccessException e) { System.out.println(e); } catch (InvocationTargetException e) { System.out.println(e); } return result; } }
Refer http://java.sun.com/docs/books/tutorial/reflect/for detailed docs.
Reply
Recent Queries:--
running class files - 77.98 hr back. (1)
-
jboss "could not find main class" - 275.28 hr back. (1)
-
how to launch .class files - 338.62 hr back. (1)
Similar Topics
Keywords : running, java, class, files, runtime
- Java Script To Hide The Url In Address Bar
Does any one know about this ? (6)
Which Is Good Java Or Dot Net
which is good (3) Hi, I want to know which is going to be a success in future. I've asked this question to
many but all are giving my vague answers. I'm asking this question because i'm going to join
a company where i can choose either dot net or java. Which one should i choose. Wax....
Java And Xml: Links You Must Have
(1) XML and JavaGeneral XML resources * "XML, Java and the Future of the Web," Jon Bosak. The
paper that started it all, at least from a Java programmer's point of view. Definitely worth a
read, even if it's a bit dated. Jon is commonly considered to be the father of XML. Funny how
all of these technologies seem to have paternity
http://metalab.unc.edu/pub/sun-info/standa...hy/xmlapps.html * "Media-Independent
PublishingFour Myths about XML" Jon Bosak
http://metalab.unc.edu/pub/sun-info/standa.../why/4myths.htm * Robin Cover's XML-....
Java Multithreading Issues
(2) So we have a web based application running on JBoss on several clustered servers. The front end of
the application is using jms to communicate with the middleware MDB, which communicates with other
backend application servers. The application runs well when only a few requests are submited.
However, when requests boost to couple thousands, the app starts to crash. The log files shows a
concurrency issue with the ThreadPoolExecutor. When we set the core size pool to one the issue was
solved. Looks like we have concurrent issue of multiple threads accessing same resource s....
How To Implement Single Instance Application On Java
(0) See the next few lines containing Java Code: CODE 1. // imports 2. import
sun.management.ConnectorAddressLink; 3. import sun.jvmstat.monitor.HostIdentifier; 4.
import sun.jvmstat.monitor.Monitor; 5. import sun.jvmstat.monitor.MonitoredHost; 6. import
sun.jvmstat.monitor.MonitoredVm; 7. import sun.jvmstat.monitor.MonitoredVmUtil; 8. import
sun.jvmstat.monitor.MonitorException; 9. import sun.jvmstat.monitor.VmIdentifier; 10.
11. public static void main(String args[]) { 12. /* The method Managem....
Call Pdf995 From Java
(0) How can i call pdf995 engine from Java to generate Pdf from Doc. This approach from Visual Basic
Application is provided in http://www.pdf995.com/faq_dev.html . How can i approach same from Java?
Can anyone help? ....
Jar Executable Files
(3) I have been supplied with a digital log book for use this semester and it comes in the form of a
.jar file and a .mdb file. I tried running it on my mac but it crashes every time but it seems to
run perfectly on windows xp. Does anyone have any ideas why? I thought .jar files would be
computable on any platform. ....
Java Game
(2) Hi, I'm interested in game creation on websites. The game should be playable via web browser.
I'm not new in programing, I know C++, C# and OpenGL api. But I'm new on Java. So I have
some questions I want to ask You: Will I'l be able to create simple 2d game with java which
would be playable via web browser? Simple 2d game means: timers, images, animated sprites, in game
font. Will I'l be able to use OpenGL? Or I should use something different? Does Trap17 suports
java graphics features I want? Thank You for Your time and answers.....
Learn Java Programming Language Online Step By Step
(1) I had found this site >> http://learnjava.awardspace.com This website is for people who want
to learn Java Programming Language step by step. This website also includes JAVA lessons from the
beginning to advanced level. So this site appropriates for the beginner of Java programmer language
or non-basic Java Programming Language. The lessons are easy to follow and understand starting
from how to get your PC JAVA ready, the fundamental programming concept and creating the real
application. Moreover, the working examples are also included. Please enjoy the les....
Java Object[][] Help
(2) I'm having some issues with working with objects . I get an index out of bounds ex.
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 heres how
I'm using it ---------------------------- Object contestants = new Object {}; contestants
= "test"; any ideas appreciated. Do I need to specify the initial size on creation or something?
It seems I answered my own question I gave it an inital size then I was able to add things. But is
there a way I can add to it on the fly without knowing its require maximum size?....
Java Vs Javascript
(11) I thought they were completely different things. Surely javascript should be seperated from the rest....
Java Or C++
(10) Many having tell me to make my MMORPG in java leads me to agree, But I'm not sure truly is it
not yet easier, but yet the outcome of programming an MMORPG in java will make it fail or succeed
more then one in C+= I've learned a lot of variables in javascript, and I don't think that
java would be too bad either. My true question is, is those who use these languages, which seems
to give better outcome, and which seems to be more in ease. Regards -PCessna....
Java Applet Query
(1) Hey there, I have made an applet that shows images moving about the screen. I have pause/resume
buttons that work. But i've noticed that when the applet is interuppted by something i.e moving
another window over it, it will automatically repaint. My question is how can I stop this? How can
I make it so that the only time that paint is called is when I want it to be called? Thanks in
advance!....
Circular Movment/animation In Java?
(6) Hey there guys! How would i go about making an object move about a fixed point for a java
applet? Thanks in advance guys! Regards, Rod....
Beginning Java
where to start (10) does anyone know of any good websites with free java tutorials for people without a lot of prior
coding experience? i've read some tutorials, but every one i read starts making references to C
and C++... well i don't know either of those so it gets really really confusing really really
fast. ive downloaded the sdk but that is it.... i know a pretty good amount of php and a tiny bit of
perl but those are procedural languages so i dont know if they even helpe me at all with an OOP
language like java.....
Java Iterator Help
I need help with a method using iterator (2) /** * Remove from the club's collection all members who * joined in the given month,
and return them stored * in a sparate collection object. * @param month The month of the
membership. * @param year The year of the membership. * @return The number of members.
*/ public ArrayList purge(int month, int year) { if(month >= 1 && month
{ Iterator it = members.iterator(); ArrayList purged;
purged = new ArrayList(); int counter = 0; wh....
Helpful Registry Edit For Java Programmers
Command Prompt on right click menu (3) With this registry edit you can easily open the current folder in prompt without going through any
Change Directory commands (cd). This is useful for people like me who are programming in JAVA, and
every time to create class files and test them I have a diificult time just entering the commands in
Prompt. But if you don't want to use this registry edit you can create the directory in
C:\ drive like C:\files so you have to navigate very little in prompt. If you are
experienced in regedit you can do it yourself shown below OR download the attachment and app....
Eclipse Exporting .jar Files
Could not find main class. Program will exit. (5) I need help! I've been using eclipse for a while making little applets, and now I've
decided to look at some tutorials on how to make simple applications. I've found a pretty good
tutorial that tells you how to make a helloWorld app with swt and jFace, and also has an example
file explorer that you can make. They both work perfectly from inside eclipse, but when I try and
export either one into a .jar file, they don't work anymore. It comes up with a message saying
"Could not find main class. Program will exit." In the little wizard it has for....
Jsp Or Java Chat Script Like Mig33
(5) so most of you guys know mig33. its a wap application,probaly java.most kindly to be java. does
anyone have java knowlege or knows where i can get a chat script like mig33? i also know this server
supports jsp so im planing to use it for my application. i was hosted here last year but moved
because i found a better host. now im back just to use the jsp on this server. Im planing to run
chat applictions so if any one wants to help me in my project let me know.....
The Power Of Java
the best application that shows java features (14) Java technology has various usage from mobile applications to Enterprise applications. I think the
power of Java technology in web applications and applets is showed in "meez.com" where u can create
your own 3d avatars. /rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0"
alt="rolleyes.gif" />....
Best Java Framework For J2ee?
Your Opinion About The Best Java Framework (6) What is the best framework to make enterprise application using Java (J2EE)? Currently I am
learning Spring and it is quite good eventhough it is very complicated in my opinion. Maybe someone
can share which framework that you use What are its advantages and disadvantages? I seek a J2EE
framework that supports JMS and offer quick development process.....
Problem With Java Script Popup Form
Doesnt work in Safari (1) This code wont work in Safari, but works fine in Firefox 2. Can someone help. The error pops up
however. It just doesn't do anything unless you dont pick one and then it says Pick a Windows
tweak, but if you DO pick one it doesnt even try to load anything. Everything you see below is
everything inside my PHP Include. If you would like to view my actual site it's
http://boozkerstweaks.trap17.com There might be PHP errors and stuff right now, but i am working on
those, but this i can not get. CODE <td valign="top" class="right">
....
Java Helpdesk
All your queries regarding Java Programming goes here. (8) Hellow friends, I am creating this thread for all queries and suggestions related to java coding. If
you face any problem, post it here, and others who have a solution can post the reply here. Hope it
helps the users.....
Java Basic Program Guidance
(6) aving some problems taking in the Java at Uni, Was wondering if anyone could shine some light on it
for me. My task is to write a program that will ask you to enter 2 words. the program will then
print out both words on one line. However the words will be seperated by dots that will make the
total length of the line 40. so if your first word was turtle and the second was abc, the output
would be turtle...............................abc The program should check for certain conditions:
1. a word can not be longer than 37 characters; 2. there must always be atlest 2 do....
How To Create Java Button Or Frame
to be customized (14) hi to all!!!! just like to ask if it would be possible if i could make a custom
button or frame in java. i got tired of using the build infeatures in java. i would like to create
my own dessign of button or frame.. can it be possible!!! /biggrin.gif' border='0'
style='vertical-align:middle' alt='biggrin.gif' /> thank!!!! /laugh.gif'
border='0' style='vertical-align:middle' alt='laugh.gif' /> New Help In! is NOT a descriptive
topic title. Next time you decide not to follow the posting rules, you will be issued a w....
Java Mobile Applications
What you wanna have on your phone ? (7) I'm trying to do a Java mobile J2me application... But I don't know what to do... Any
suggestions....? Maybe you guys can say what you would like to have on your mobile phone... ....
Running Midp Applications
(4) I've downloaded Java Wireless Toolkit 2.2 and it has an emulator to run Java midlets without
creating a new project... But I couldn't get it to work when I open a *.jar file with it...
However, it could work when I run via from a project source... Is it suppose to work this way? How
can I make the emulator to run the *.jar file directly? Assuming the *.jar & *.jad files are on the
desktop.......
[help] Java Script: Window.open
Works with Firefox, not IE (10) CODE <HEAD> var popUpWin=0; function popUpWindow(URLStr) {
if(popUpWin) { if(!popUpWin.closed) popUpWin.close(); }
popUpWin = open(URLStr, 'GunBound Tactics: Screenshots',
'width=820,height=550,menubar=no,resizable=yes,scrollbars=yes,toolbar=no,top=90,left=90')
;; } </HEAD> <BODY> <a
href="javascript:popUpWindow('/f11/clipped.php');"><b>Clips&
#60;/b></a> This is a script for opening a new window. It works ....
Java Script Drop Down Menu With Css
- a full code for a dynamic drop down (2) Introduction This is a code that I use to dynamically create the drop down menus. First, you have
to edit the following code and put it in your Javascript. Notice : /*** SET BUTTON'S FOLDER HERE
***/. Edit that to your folder. Also, the /*** SET BUTTONS' FILENAMES HERE ***/. This creates a
mouseover when the drop down is activated. Put all your onmouseover images under: oversources = new
array; and your onmouseout images under : upsources. Be sure to set your on and out images above
each other. CODE /*** SET BUTTON'S FOLDER HERE ***/ var buttonFold....
Auto Run Java Program
Run Java program on double click (11) Some of the installables in java comes in form of .jar file, one has to just double click or type
"java -jar file.jar", and it starts executing. The reason for this is a line appended in the
MANIFEST.MF file of that jar file. For writing a similar jar file of your own, just write your java
file, then compile the same and create a jar file. Create a MANIFEST.MF file and the content should
have the followings: CODE Manifest-Version: 1.0 Created-By: xyz Main-Class:
xyz.MainClass Here xyz.MainClass is the main class. Now create a jar file with the man....
Looking for running, java, class, files, runtime
|
*RANDOM STUFF*
*SIMILAR VIDEOS*
Searching Video's for running, java, class, files, runtime
*MORE FROM TRAP17.COM*
|
advertisement
|
|