Call(execute) a class in another class
Hi,
please I am a newbie in java and I want call and show the result of algorithm in a method of another class
the algorithm that I use is apriori algorithmhttp://www2.cs.uregina.ca/~dbd/cs831/notes/itemsets/itemset_prog1.html, that algorithm should use two files like arguments:config.txt and transa.txt when I excute this algorithm in line command the algorithm output is file called apriori-output.txt so i want excuteafter show result of this algorithm inside a class called JadeProject and and more specifically in method called setup()
so how can call and execut this algorithm
thanks in advance
Hi gimbal2,
thank you for your reply,
My problem is the following:
my question is how can I execute the apriori algorithm inside the agent code (java class)
I want to build multi agent system using jade(framwork based in java language it is used to build multi agent system) my multi agent system is composed in many agents
those agents are juste java classes
My aim is to execute an algorithm(java class) in agent class
this algorithm is the data mining algorithm apriori http://www2.cs.uregina.ca/~dbd/cs831/notes/itemsets/itemset_prog1.html
the apriori algorithm use two text files :config.txt and transa.txt
i put the algorithm aprioir and the two files in the same directory and i compile the algorithm java class in line command
the output of the execution of algorithm is generating in text file called apriori-output.txt
but I am using netbeans and no line command
my question is how can I execute the apriori algorithm inside the agent code (java class)
thank you in advances
Similar Messages
-
How to call a Java class from another java class ??
Hi ..... can somebody plz tell me
How to call a Java Class from another Java Class assuming both in the same Package??
I want to call the entire Java Class (not any specific method only........I want all the functionalities of that class)
Please provide me some slotuions!!
Waiting for some fast replies!!
Regards
Smita MohantyHi Smita,
you just need to create an object of that class,thats it. Then you will be able to execute each and every method.
e.g.
you have developed A.java and B.java, both are in same package.
in implementaion of B.java
class B
A obj = new A();
//to access A's methods
A.method();
// to access A's variable
//either
A.variable= value.
//or
A.setvariable() or A.getvariable() -
How do you call a java class from the main method in another class?
Hi all,
How do you call a java class from the main() method in another class? Assuming the two class are in the same package.
Thanks
SI
Edited by: okun on May 16, 2010 8:40 PM
Edited by: okun on May 16, 2010 8:41 PM
Edited by: okun on May 16, 2010 8:47 PMgeorgemc wrote:
To answer your impending question, either the method you're calling has to be static, or you need an instance of that other class to invoke it against. Prefer the latterAnd to your impending question after that: no, don't use the Singleton pattern. -
Displaying the output from a java class executed from W/I another class
I have compiled a java class, but I have run into a problem executing the class. I have read the posts and still have not solved the solution. I have tried to get the output of the Process by using "proc.getOutputStream().toString()", however it displays it in binary (ex. java.io.BufferOutputStream@48eb2067). If anyone can provide any assistance I would greatly appreciate it. Or if you could tell me if I'm on the right track or not. Thanks ALL. Here is a code segment:
int truncStart = s.indexOf(".java");
s = s.substring(0,truncStart);
String[] command2 = {"java","c:/"+s};
try
//JOptionPane.showMessageDialog(null,"Exec. File "+s, "Exec. File : ",JOptionPane.ERROR_MESSAGE);
proc = Runtime.getRuntime().exec(command2);
JOptionPane.showMessageDialog(null,"Output: "+proc.getOutputStream().toString(),"Output"
,JOptionPane.ERROR_MESSAGE);
}You have to read the stream, like:
InputStream stream = proc.getOutputStream();
// now use methods on stream, such as read() to read the characters/lines - or wrap it in another line-friendly stream - see the java.io.* classes - keep reading until you get an end-of-stream indicator, depending on the API you end up using. -
How sholud we call one jframe class from another jframe class
Hi
In my application i am calling one jframe class from another jframe clas.
how sholud we make previous jframe inactve when another jframe is invoked?(user sholud not able to make any changes on on parent jframe window when another jframe is invoked)
Pls reply.Sorry for me it is not possible to change existing code,
pls suggest me any other solution so that i can inactive parent jframe when child jframe execution is going on. -
How can I call a java class from within my program?
I was wondering if there's a platform independent way to call a java class from my program.
Here's my scenario. I'm working on a platform independent, feature rich, object-oriented command prompt program. The way I'm designing it is that users can drop classes they write into my bin directory and gain access to the class through my program. For example, they drop a class named Network.class in the bin directory. They would type Network network at my command prompt and gain access to all the methods available in that class. They can then type system.echo network.ipaddress() at my prompt and get the system's ip address. I have it designed that there's a server running in the background and the clients connect to my port. Once connected the end-user can enter their user name and password and gain access to the system. When they type a command they actually call another java program which connects to my server using a seperate thread. They can then communicate back and forth. I have it set that everything has a process id and it's used to keep track of who called what program. Once the program is done it disconnects and closes. Rather than getting into the nitty gritty (I didn't want to get into heavy detail, I know how everything will work) I'm really interested in finding out how I can call a java program from my program. I don't want it to be part of the app in any way.
-
Java.lang.NoClassDefFoundError while calling a java class from BPEL
Hi,
I'm calling a java class to convert JSON to XML using BPEL. I have imported all the necessary jar files in the project and compiling done successfully.
But at runtime , i get the java.lang.NoClassDefFoundError: net/sf/json/JSON error.
For this i placed all the necessary jars under FUSION_HOME/Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1/ path and restarted the server.
But still i'm getting the same error at runtime.
Did i missed any step? Let me know the procedure to solve this.
Do i have to run ant or edit Manifest file after placing the jar?
in one site i find we have to place the jars under <DOMAIN HOME>/lib directory. Is this correct?
We are using SOA suite 11.1.1.6.
Thanks,
TerryHi Karan,
I have done placing the jars at FUSION_HOME/Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1/ and ran ant -f build.xml .The build was successful without any error.
I have even placed the jars in <DOMAIN HOME>/lib (/us2001/fmw/11.1.1.6/user_projects/domains/ohsdomain/lib) and did a server restart.
After these activities, when i execute the composite, i still get the error in em console,
Message
got RuntimeException
Supplemental Detail
oracle.fabric.common.FabricException: Could not create object of class 'packageName.className'; nested exception is:
java.lang.NoClassDefFoundError: net/sf/json/JSON
at oracle.integration.platform.blocks.wsif.WsifReference.request(WsifReference.java:698)
at oracle.integration.platform.blocks.mesh.SynchronousMessageHandler.doRequest(SynchronousMessageHandler.java:139)
at oracle.integration.platform.blocks.mesh.MessageRouter.request(MessageRouter.java:182)
Any help on this.
Thanks,
Terry -
Error while calling badi using class cl_exithandler with getInstance
hi experts...we are using SAP ECC 6.0 version
I have created BADI Def and Implementation using se18 and se19 with some interface methods..
Problem:
I'm writing a report to call that using class CL_EXITHANDLER but it shows an Exception..
" Exception condition "DATA_INCONS_IN_EXIT_MANAGEM" raised."
Report example:
DATA: CL_EXIT TYPE REF TO CL_EXITHANDLER,
IF_USER_INSTANCE TYPE REF TO ZIF_EX_USER_MAILID1.
CALL METHOD cl_exithandler=>get_instance
EXPORTING
EXIT_NAME = 'ZBADI_USERMAIL_DEF'
* NULL_INSTANCE_ACCEPTED = SEEX_FALSE
* IMPORTING
* ACT_IMP_EXISTING =
CHANGING
instance = IF_USER_INSTANCE
* EXCEPTIONS
* NO_REFERENCE = 1
* NO_INTERFACE_REFERENCE = 2
* NO_EXIT_INTERFACE = 3
* CLASS_NOT_IMPLEMENT_INTERFACE = 4
* SINGLE_EXIT_MULTIPLY_ACTIVE = 5
* CAST_ERROR = 6
* EXIT_NOT_EXISTING = 7
* DATA_INCONS_IN_EXIT_MANAGEM = 8
* others = 9
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
so i found that all EXITs are in the Table " SXS_ATTR"
but what i have created BADI has not exist in that Table so that it gets an Exception(while i'm debugging found this)
so kindly tel me whats problem my BADI "ZBADI_USERMAIL_DEF" not maintained that Database table
but in Implentation class its working fine..yes i have created badi in Enhancement spot so regarding what u told i'm using GET BADI and CALL BADI
DATA:W_HANDLE TYPE REF TO ZBADI_USERMAIL_DEF.
GET BADI W_HANDLE.
CALL BADI w_handle->get_user_mailid
EXPORTING
uname = UNAME
changing
mailid = W_EMAIL
WRITE: / 'UNAME:',UNAME.
WRITE: / 'EMAIL ID',W_EMAIL.
CALL BADI w_handle->get_user_address_data
EXPORTING
uname = UNAME
changing
addrdata = W_ADDRDATA
IF W_ADDRDATA IS NOT INITIAL.
WRITE: / W_ADDRDATA-BNAME,W_ADDRDATA-NAME1,W_ADDRDATA-NAME2,W_ADDRDATA-TELPR,W_ADDRDATA-TELNR,W_ADDRDATA-TEL01.
ENDIF.
but here BADI are not called
Interface implementation class methods not executed so kindly tel me whats problem here.
Thanks in Advance
sivakumar -
I want to call External Java class from the PL/SQL
Hi,
I am using Oracle Apps R11i (11.5.7), I wanted to call external Java class from the PL/SQL. This external Java class is residing in another application server.
How do I do this.
I know one way. Develop C routine in Oracle Apps to call external java class and call this C routine from the PL/SQL.
Is there any simple method available? or any other method?
Thanks in advance.
-VenkatFirst of all, this is a Java application you're talking about, right (i.e. it has a main() function)? It's not just a class that you're trying to instantiate is it? If it's an application, you obviously have to start a new virtual machine to run it (rather than using the virtual machine built into the database like stored java). I'm a little leary of your mention of an "application server" as this would more commonly mean that a virtual machine is already over there running with access to this class. In which case, you'd typically interface with SOAP or some other RPC API.
All that aside, as long as you have physical disc access (through NFS or whatever) to the class file, you could use a java wrapper class with a system call to do this. In fact, there is a thread in just the last day or so on this very forum that has the code to do just that (see " Invoking OS Commands from PL/SQL"). However, it's worth noting that the virtual machine will be running on the database server in this case and not the application server. -
Calling a java class in JSP in Weblogic 5.1
Hi
I am trying to call a java class in a jsp page. But it is giving an error:
Compilation of 'C:\weblogic\myserver\classfiles\jsp_servlet\_knet\_buy.java' failed:
C:\weblogic\myserver\classfiles\jsp_servlet\_knet\_buy.java:79: cannot access jsp_servlet._knet.e24PaymentPipe
probably occurred due to an error in /knet/buy.jsp line 25:
e24PaymentPipe pipe = new e24PaymentPipe();
Is this a problem bcos of the wrong path of the class file which i am calling?
Please help this is urgentHello All
As I tried to deploy the easiest project (dummy.war) on WebLogic 8.1.5, There is only one class (without package) Login.class
*********** Listing of the dummy WAR ***********
META-INF/
META-INF/MANIFEST.MF
WEB-INF/
WEB-INF/classes/
WEB-INF/classes/Login.class
WEB-INF/web.xml
index.jsp
login.jsp
************ Output of deployment from Admin Console****************
Log:
A log of the task's activities.
[Deployer:149033]preparing application dummy on intranetAdmin
[Deployer:149033]prepared application dummy on intranetAdmin
[Deployer:149033]activating application dummy on intranetAdmin
[Deployer:149033]failed application dummy on intranetAdmin
[Deployer:149034]An exception occurred for task [Deployer:149026]
Deploy application dummy on intranetAdmin.:
Exception:weblogic.management.ApplicationException: start() failed.
Module: dummy Error: weblogic.management.DeploymentException:
[HTTP:101216]Servlet: "index" failed to preload on startup in Web application:
" dummy ".
weblogic.servlet.jsp.CompilationException: Compilation of D:\apps\wlsapp\
INTRAN~1\.\intranetAdmin\.wlnotdelete\extract\intranetAdmin_ dummy _ dummy
\jsp_servlet\__index.java failed.
D:\apps\wlsapp\INTRAN~1\.\intranetAdmin\.wlnotdelete\extract\
intranetAdmin_dummy_dummy\jsp_servlet\__index.java:22: '.' expected
import Login; //[ /login.jsp; Line: 8]
^
1 error
at weblogic.servlet.jsp.JspStub.compilePage(JspStub.java:478)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:246)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:196)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.
java:3430)
at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.
java:3387)
at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext
.java:3373)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:3356)
at weblogic.servlet.internal.WebAppServletContext.setStarted(WebAppServletContext.java:
6208)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:864)
at weblogic.j2ee.J2EEApplicationContainer.start(J2EEApplicationContainer.java:2134)
at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2175)
at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.
activateContainer(SlaveDeployer.java:2520)
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.doCommit(SlaveDeployer
.java:2438)
at weblogic.management.deploy.slave.SlaveDeployer$Task.commit(SlaveDeployer.java:2155)
at weblogic.management.deploy.slave.SlaveDeployer$Task.checkAutoCommit(SlaveDeployer.java:2254)
at weblogic.management.deploy.slave.SlaveDeployer$Task.prepare(SlaveDeployer.java:2149)
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeployer.
java:2401)
at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:
883)
at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:591)
at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:500)
at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:25)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
Caused by: java.io.IOException: Compiler failed executable.exec
at weblogic.utils.compiler.CompilerInvoker.compileMaybeExit(CompilerInvoker.java:470)
at weblogic.utils.compiler.CompilerInvoker.compile(CompilerInvoker.java:328)
at weblogic.utils.compiler.CompilerInvoker.compile(CompilerInvoker.java:336)
at weblogic.utils.compiler.CompilerInvoker.compile(CompilerInvoker.java:321)
at weblogic.servlet.jsp.JspStub.compilePage(JspStub.java:451)
... 22 more
- with nested exception:
[java.io.IOException: Compiler failed executable.exec]
I put this class into a dummy package named sample, changed package declaration within this class and changed import statement within jsp pages like this :
<%@ page import="sample.Login " %>
<jsp:useBean id="logUsr" scope="session" class="sample.Login" />
When I did like this, everything is ok. No more exception.
If my application has so many java classes under WEB-INF/classes/ without creating package, it may be so inconvenience.
Please kindly let me know why this exception (class not found exception) occurred.
And what is the solution? I cannot deploy the application successfully yet.
many thanks,
Zin Ko Win -
Calling a java class in a JSP file
Hello,
I have a jsp file in which I call a java class.
I work with Tomcat 4.0.1
If I modify the java class and then I execute my JSP, it still be the old version of my class that is executed.
I don't understand why since if I creates a main function and I execute it, it works correctly!
Do you know what is the problem?
Thanksi also have this problem.when i modify jsp file,it didn't execute inmediately. Then i restart tomcat,but problem also exist.
a few minute age,i execute jsp file again,it can appear the modified jsp.i don't down why
i work tomcat 5.0 windowxp -
Jsp session variable to call in java class.
here i am facing a problem in calling a jsp session varibale to java class.
in my code.. i have seperate files for jsp pages and packaged java classes.
as i am developing a web tire application. the data entered in the front end i am getting to jsp page and putting the mandatory in session to use in other pages. now here the same session vaiable i have to use/call in java class file.
Please refer me the best method and any references on this to call the session vaiable to java class file.
in jsp page i decleared like this:
session.setAttribute("stuIdentification",stuid);
this id i have to use in java class.file.
how to call it?
Thanks
KurraGimbal2's got the right idea.
The reasons for choosing point 1) are also valid. Whenever possible try and do as much code that is not specifically tied to your business objects inside your dynamic element (the jsp page) instead of your static one (the compiled class)
this allows you to very easily update your jsp to make any changes without having to recompile class code. Recompiling seems like a little thing when you are in development but imagine if the class is executed by a business critical application that faces forward to customers, recompiling will mean shutting down your servers and that may not be an option.
Regards,
David -
Problem Calling a Java class from PLSQL function
We are calling a Java class through oracle function as
FUNCTION CalculateAMW (contributorid IN Number,
fromdate IN Date,OHorAnncoverage in Number,
OHAnncoverage in Number,
AppStatus in Number,
Status in Number)
RETURN Number
AS LANGUAGE JAVA
NAME 'AMWCalculations.calculateAMW
(long,java.sql.Timestamp,long,long,long,long) return double';
on execution of this function the sql prompt for the 1st time it is giving the output
but
if reexecute it is throwing and error ORA - 932 : Inconsistent
datatypes.
Recompiling the java class then it works for the 1st time and the next
time
we execute it throws error as explained above.
What could be the problem.
Thanks
Nanda Kishoreany idea???Yes, you are in the wrong forum, this is a Java forum, you have an ASP question, so i suggest you visit an ASP forum/site
-
Can we call a custom class from a servlet
Hi
Can we call a java class (not a delivered class by java) in a servlet. I am trying to call API.class which is written by me in a servlet. It is not giving an error at the import stage. But when i am trying to initialize the class object it is throwing up the following error:
Error 500--Internal Server Error
java.lang.NoClassDefFoundError: psft/pt8/joa/API
at knet.Creditcall.(NBKServlet2.java:61)
at knet.NBKServlet2.doGet(NBKServlet2.java:49)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:915)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:879)
at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:269)
at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:365)
at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:253)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)Did you deploy your class with the web app? You can do this by placing your classes in a jar, and put that jar into the WEB-INF/lib folder or by copying your classes into WEB-INF/classes.
-
Getting the calling object reference / class?
Dear forum members,
Is it possible for A in the below example to get that B was the "caller"?
class A {
A() {
public void someMethod(String text) {
System.out.println("I was called with: " + text);
System.out.println("I was called by: " + thatMagicWayToGetCallerClassOrReference());
class B {
public static void main(String[] args) {
A a = new A();
a.someMethod("HOLA HOLA");
}Another way of getting the class of your caller is to use a SecurityManager object. getClassContext() is protected but you can get at it by subclassing SecurityManager (it works if you just instanciate the manager without installing it). This gives you a reference to the Class object itself where the stack trace returns only the class name. Bear in mind that the class in question will be several items up the array, the first entry is the SecurityManager itself, the second the called class.
However, I agree with others it doesn't sound like the best design. If you're having trouble with not being able to change the interface specifications to pass the extra information then consider using a static reference, if necessary a ThreadLocal. What happens if you want to call the offending method indirectly through some central method at some future time? You've lost the call origin data.
Why can't you simply add a parameter to the offending call?
Maybe you are looking for
-
Internal order with bught process
Hi All, Any one please clear my point Exam. We have one Internal order for Business area A and we give the Budget for that Internal order, Now we post the same posting in that Internal order and closed the Internal order (In that Internal order still
-
Same volume for all songs in your iPod?
Is it for real "iVolume 2.0.2 for the Mac"? Or another application? Did someone tried it, and it really worked? It is worth while buying it? I have some old CDs I bought years ago and they have really diferent volume level. Thank you in advance.
-
Could someone advise me on a fix for my compiler
I have Xcode installed with both gcc-3.3 and gcc-4.0.1... BUT... i think that there is another version (gcc-4.1.1) floating around that I must have inadvertantly (or advertantly, but long enough ago that I don't remember doing it) installed through w
-
hai, what are the elements of sales organisation,explain
-
Error Command is disabled - from lwapp CLI
Hello, i keep getting this message when trying to restore back to default or clear controller ip definations in the lwapp ap. How do i get around this?