Java code to read Java Program
Hi,
Is there any standard api to retrieve the java program's class name, method name, its parameter, code etc...
My req is to write a java program that takes any java programme file as input and returns the class name, method name, parameter name and type etc...
Thanks,
Santhosh.
Take a look at the annotation processor atp in the standard Java toolkit. It provides a framework for scanning Java source files visiting types, fields etc.
Or you could get hold of javacc, which comes with an example schema for reading Java source.
Similar Messages
-
How to write java code to read the pixel color in some place of screen?
Hello all:
How to write java code to read the pixel color in some place of screen?
The java application iteself doesn't have any GUI.
thank you
-DanelSee java.awt.Robot
-
How do I pass an error status from my java code back to the Program Job Ser
How do I pass an error status from my java code back to the Program Job Server?
I have a jar program object that reports a scheduled status of "Success" even if the java code errors out.Exceptions thrown from the program object are ignored by the program job server.
You need to configure the Program Object, then stream out a special string sequence to the stdout of the Program Object, to set the scheduled instance status to Failed.
Look up SAP KBase 1201804 - How to programmatically set the status of a Program object to "Failed"
Sincerely,
Ted Ueda -
Sample java code which reads xml attributes using DOM Parser
Hi Friends,
I am looking for a sample java code which uses the DOM Parser to read the attributes values.
My xml looks like below
<?xml version='1.0' encoding='UTF-8'?>
<root>
<header unid="100" status="true">
<validation stage="1" processed="10"/>
</header>
</root>
Experts please help...
Thanks in Advance
JJYou have probably found lots of resources on the www for this by now, if not: [http://www.w3schools.com/dom/default.asp|http://www.w3schools.com/dom/default.asp]
-
Java code samples for java mappings
Dear all,
Can you please send me a sample scenario in which you used the java mapping.
How do we assign the source structure,the target structure.
How do we map source->target
Do we give the source and target interface names in execute method)?
if so where do we map the same.
we have one to one mapping in graphical,message mappings which i worked with.
is there any tool for making the same thing in java?
Kindly send me the documents if any on java mapping to [email protected]
Please clarify.....ref:
/people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
/people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii
and
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/javaMappingSample+Code& -
How to increase heap size in java code, not using "java -Xms64m "
Im writing a java programme for loading the german dictionary. my dictionary is very huge(around 300000+ words).
while loading the dictioanry im getting error "OutOfMemoryError" .
I found one solution to increase the heap size, but i want to increase the heap size in java programmer itself, not outside jar file. so i could not use "-Xms64m" option of jvm.
Can anyone tell me how can i do thissunlover1984 wrote:
Im writing a java programme for loading the german dictionary. my dictionary is very huge(around 300000+ words).
while loading the dictioanry im getting error "OutOfMemoryError" .
I found one solution to increase the heap size, but i want to increase the heap size in java programmer itself, not outside jar file. so i could not use "-Xms64m" option of jvm.
Can anyone tell me how can i do thisThat option is a startup option for the JVM. That means if your jar is already loaded then you are already too late to try and call it. -
Java code to connect to unix box(putty)
i'm having a great problem regarding accessing the putty box from java code.
I need to read some log files from unix through java code.In my client program when i'm giving hostname and port=22...ssh terminal is getting detected,but i'm confused how to open that unix box by giving the username and password.and how am i goin to embed unix command in it.The entire job i've to do through java code.
please help!!..Thanks
Message was edited by:
liz310
Message was edited by:
liz310thanks a lot guys for ur time...but i tried in every way..i'm getting hell lot of errors..please help..its really urgent
/*this is my code:*/
import com.jcraft.jsch.*;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.UserInfo;
import java.io.*;
public class shell_test {
public static void main(String args[])
String user="user15";
String host="punlin040";
String cmd="ls -l";
JSch jsch = new JSch();
try{
Session session=jsch.getSession(user,host,22);
session.setPassword("user15");
//UserInfo usrInfo=new MyUserInfo();
//session.setUserInfo(usrInfo);
session.connect();
Channel channel=session.openChannel("exec");
((ChannelExec) channel).setCommand(cmd);
channel.setXForwarding(true);
channel.connect();
//code
channel.setInputStream(System.in);
// channel.setOutputStream(System.out);
//((ChannelExec) channel).setErrStream(System.err);
InputStream in = channel.getInputStream();
channel.connect();
byte[] tmp = new byte[1024];
while (true)
while (in.available() > 0)
int i = in.read(tmp, 0, 1024);
if (i < 0)
break;
System.out.print(new String(tmp, 0, i));
if (channel.isClosed())
in.close();
// System.out.println("JSCH: exit-status: " +
//channel.getExitStatus());
break;
try
Thread.sleep(1000);
catch (Exception ee)
channel.disconnect();
session.disconnect();
//code
//ch.setInputStream(System.in);
//ch.setOutputStream(System.out);
}catch(Exception e)
{e.printStackTrace(); }
/*public static class MyUserInfo implements UserInfo {
public String getPassword()
{ return "password"; }
public String getPassphrase()
{ return ""; }
public boolean promptPassword(String arg0)
{ return true; }
public boolean promptPassphrase(String arg0)
{ return true; }
public boolean promptYesNo(String arg0)
{ return true; }
public void showMessage(String arg0)
but i'm getting following errors:
com.jcraft.jsch.JSchException: java.lang.ClassNotFoundException: com.jcraft.jsch
.jce.Random
at com.jcraft.jsch.Session.connect(Session.java:160)
at com.jcraft.jsch.Session.connect(Session.java:145)
at shell_test.main(shell_test.java:25)
Caused by: java.lang.ClassNotFoundException: com.jcraft.jsch.jce.Random
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.jcraft.jsch.Session.connect(Session.java:156)
... 2 more -
How can i add more statements in java code dynamically...
I have a (business works) BW process in TIBCO which has many activities including �java code�. In java code activity I have some if statements like
if (Country.equals("USA�))
Country code = 1
else if(Country.equals("GERMANY�))
Country code = 49
the above information is coming from database. now my project is deployed and running. In future, if they add more countries in database how I can include them dynamically without changing my BW process java code activity and redeploying again. Is there any solution?
Please advice.You won't reconfigure the Java application without redeploying. This is one of the reasons that including data in the code is bad.
If you created a file which contained data like this:
Canada <tab> 1
USA <tab> 12
Germany <tab> 6
Then your program could read the file into a map. The map could be used to lookup the country code based on the name.
In the future, you could change the file to:
Canada <tab> 1
USA <tab> 12
Germany <tab> 6
France <tab> 17
China <tab> 2
And the program wouldn't need to be changed. You would just need to send out the new country file. -
How to Configure the Datasource In JNDI and access it through Java Code
I have declared under web.xml
<resource-ref>
<res-ref-name>MSDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
Under Jrun-resource.xml
<data-source>
<dbname>xxxxxxx</dbname>
<driver>macromedia.jdbc.sqlserver.SQLServerDriver</driver>
<url>jdbc:macromedia:sqlserver://xxx.xxx.xx.xx:1433;databaseName=xxxxxxx</url>
<username>xxxxxxxx</username>
<password>xxxxxxxxx</password>
<encrypted>false</encrypted>
<encryption-class>jrun.security.JRunCrypterForTwofish</encryption-class>
<native-results>true</native-results>
<remove-on-exceptions>true</remove-on-exceptions>
<pool-statements>false</pool-statements>
<initial-connections>1</initial-connections>
<connection-timeout>1200</connection-timeout>
<transaction-timeout>20</transaction-timeout>
<cache-enabled>false</cache-enabled>
<cache-size>5</cache-size>
<cache-refresh-interval>30</cache-refresh-interval>
<jndi-name>MSDataSource</jndi-name>
<poolname>Pool</poolname>
<minimum-size>0</minimum-size>
<maximum-size>2147483647</maximum-size>
<user-timeout>20</user-timeout>
<skimmer-frequency>420</skimmer-frequency>
<shrink-by>5</shrink-by>
<maximum-soft>true</maximum-soft>
<debugging>false</debugging>
<disable-pooling>false</disable-pooling>
<isolation-level>READ_UNCOMMITTED</isolation-level>
<description/>
</data-source>
Under jrun-web.xml
<resource-ref>
<res-ref-name>MSDataSource</res-ref-name>
<jndi-name>MSDataSource</jndi-name>
</resource-ref>
Java Code
String dsndb="java:comp/env/MSDataSource";
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"jrun.naming.JRunContextFactory");
p.put(Context.PROVIDER_URL, "localhost:2932");
InitialContext context=new InitialContext(p);
System.out.println(context.getEnvironment());
DataSource ds=(DataSource)context.lookup(dsndb);
ds.getConnection();
System.out.println(ds.getConnection().toString());
Error is
{java.naming.provider.url=localhost:2932, java.naming.factory.initial=jrun.naming.JRunContextFactory}
Exception in thread "main" javax.naming.NameNotFoundException: No such binding: MSDataSource
at jrun.naming.ContextManager.getBinding(ContextManager.java:680)
at jrun.naming.ContextManager.getBinding(ContextManager.java:686)
at jrun.naming.ContextManager.getObject(ContextManager.java:690)
at jrun.naming.ContextManager.lookup(ContextManager.java:463)
at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:501)
at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:644)
at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:470)
at javax.naming.InitialContext.lookup(Unknown Source)
at Controller.DBManager.getConnection(DBManager.java:29)
at Controller.DBManager.main(DBManager.java:42)
Please help me .
Thanks in advanceAlso, try to log the username/password in your authenticator, just to be sure that credentials changeGood piece of advice, michael. Worth of it. When I changed the credentials manually, it worked correctly,but from the application, when I logout from 'a', 'a' and log in to 'b', 'b', I got a valuable information.
I tried debugging like given below for checking from the application.
class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication() {
System.out.println("userrrrrrrrr"+UtilsHTTPS.username);
System.out.println("pwdddddddddd"+UtilsHTTPS.password);
.........................................The information I got while debugging from the application was, the username and password does not get printed. It implies that, Authenticator.setDefault(new MyAuthenticator()); does not work as desired ie; even on calling new MyAuthenticator(), it does not get inside the MyAuthenticator class.
Why does this happen? What is the solution for this? -
Access ViewObject from Java code in ADF
Hello everyone,
I've got one problem with ADF, which I can't deal with on my own.
I've created web application that consists of two UI components:
- table that displays data from database (i've created entity object/view object/application module and drag onto JSF page)
- button that can refresh table / change data in it (i've got java bean method, that do some logic on view object, which is added as a action to a button)
My problem is, that i've got SQL query, for example: "select * from dept" and I want to my view object (which I've created before) displays result of this query. How can I do it?
I don't know how from a java code (in my java bean method) access a view object and execute a sql query on it? I've got some code:
ViewObject dynamicVO = this.findViewObject("VO1");
dynamicVO.remove();
dynamicVO = this.createViewObjectFromQueryStmt("VO1", "SELECT * FROM dept");
dynamicVO.executeQuery();
but the dynamicVO is always null.
Thanks for any help.Ok, my jdev version is: Studio Edition Version 11.1.2.2.0.
I've got some problems which i can't deal with, access ViewObject in my Java class.
I will show you my project file tree:
http://i46.tinypic.com/2myxkwz.png
and
my TestClass.java:
package model;
import oracle.jbo.ApplicationModule;
import oracle.jbo.ViewObject;
import oracle.jbo.client.Configuration;
import oracle.jbo.domain.Number;
public class TestClass {
public TestClass() {
super();
public static void main(String[] args) {
String amDef = "models";
String config = "AppModule";
Configuration.createRootApplicationModule(amDef, config);
}which causes error:
Error Configuration File bc4j.xcfg is not found in the classpath
cle.jbo.client.Configuration.loadFromClassPath(Configuration.java:471)
at oracle.jbo.common.ampool.PoolMgr.loadConfiguration(PoolMgr.java:600)
at oracle.jbo.common.ampool.PoolMgr.findPool(PoolMgr.java:526)
at oracle.jbo.client.Configuration.createRootApplicationModule(Configuration.java:1513)
at oracle.jbo.client.Configuration.createRootApplicationModule(Configuration.java:1490)
at model.TestClass.main(TestClass.java:16)I found some similar topics to my, but none of them can help to solve my problem. -
How to view the java code of the message mapping,
Hi Experts,
<b>how to view the java code of the message mapping,</b>
how to get the background java code of the message mapping(graphical mapping).
And where to view it?Hi sowmya,
Open any Message mapping in IR. Press <b>CtrlShift0(zero)</b> to open a new menu.
There you will find an option "Is Java Source Code Available?"
There will be an export button nearby. Use it to get the code.
Open it in a zip , you will see the hide java code.
The JAVA code for graphical msg mapping is in below folder:
\usr\sap\<SID>\<DVEBMGS10>\j2ee\cluster\server0\temp\classpath_resolver
Here all the mapping jars are there in this folder.
Just decompile these jars and you can see the code. -
Invoke exe through java code(using java.lang.Runtime)
Iam trying to invoke an exe from java code.If i give the complete path for that exe it is running fine .But if i set the environment variable and directly execute the exe through command prompt it iss running fine , but it fails to run when i do the same using java code i.e. java.lang.Runtime.exec function
Give "//" for directory seperator.
E.g. r.exec("c://test//test.exe",null);
Why? That doesn't look correct.It is correct. It will work fine. Try it out.But it doesn't add or solve anything. A forward slash
does not need to be escaped.'
It's not even escaping. It's just doubling up. If that works, I'd bet "C://///test///////test.exe" does also. -
Hi,
I need to put some validations in web dynpro java page which is "employee address page". I checked the BADI's but no badi exists which serve my purpsoe.
Now I want to make the code change in web dynpro java. Pls answer the followng questions.
1- I have installed NWDS on my local machine. Do i need to install NWDI also?
2- How to import and export the required page and from where?
3- How to modify the standard code, I mean in ECC we have enhancement and modification concept.
Thanks,NWDI is a part of NWDS, So you would need both as mentioend
NWDI - Netweaver Development Infrastructure is an SAP sytem for java development & change management. It's a repository for java code and change management system.
NWDS is a developer tool to build applications similar to Eclipse. NWDS uses NWDI to check-in & check-out java code and move java changes to SAP runtime systems (like portal etc).
Read the basics of NWDI and its utility in the below help document
http://help.sap.com/saphelp_nwce72/helpdata/en/48/bc23b1a70a0611e10000000a42189b/frameset.htm
Also go through how to import ESS configurations in NWDI
ESS/MSS Customization Make it Simple
NWDI cookbook in SAP note : 872892
The specified item was not found.
Edited by: Siddharth Rajora on Nov 9, 2011 9:28 PM -
Class compiling/executing JAVA-Code??
Hi!
Stupid question: ;-)
Is there a possibility to "parse" Java-Code into a JAVA-Class or to give JAVA-Code to a class that compiles the code and execute it?
Thanks for answering!
Mark Hauchwitz.background: we're running servlets and simply need to "parse" specialized/customized java-code for every customer into the servlet code. Source: database or whatever...
How to get started? -
Calling a javascript function from java code and getting tha value in Java
Hi,
I would like to call a Java script function confirmRemove() from Java code upon meeting a condition..
for example the code snippet is:
if(true){
// I want to call js confirmRemove() over here. And get the value of variable "answer" in this if block.
<html>
<head>
<script type="text/javascript">
function confirmRemove() {
var answer = confirm("Are you sure you want to Delete?")
</script>
</head>
<body>
<form>...Hi,
Back in 2003 I have used an Applet which contain java code and this java code was calling the java scripts ( different methods, DHTML etc..)
There was a component developed by NetScape called JSObject I am not sure it there is other third party component other then the JSObject
look at this article which shows how (based on JSObject)
[http://java.sun.com/products/plugin/1.3/docs/jsobject.html|http://java.sun.com/products/plugin/1.3/docs/jsobject.html]
Regards,
Alan Meio
London,UK
Maybe you are looking for
-
How to support different language and print in non-english language from AS
I want to print different language that users enter in Oracle 9i AS and print reports in english and other language like spanish. How do I configure the AS Server, I am running 9i AS on Windows 2003, I have changed NLS_Lang setting in registry but it
-
My MacBook G4 and a networked Canon iR2200
Hi I am trying to connect to a Canon iR2200 (the name on the faceplate) copier/printer/scanner at my work, and am determined to get the latter two functions to work on my Mac. It si becoming an obsession with me. Please help? The Canon is connected v
-
How to add URL Icon for each responsibility
Hi all, I have a requirement where i need to add URL Icon to my custom application, i,e when i click on responsibity it will open the application so to make user to know he is in this application we need to add ICON to URL. This is possible in normal
-
Why can't I just do this...
I will be upgrading to a mac pro soon, and I was reading around on topics regarding itunes library transfer. Why can't I just drag my current user/music file to the user/music file on the new computer? I know I will be resetting all of my preferences
-
BC4JToystore - View and Controller layer problem
I am trying to create a web application based on the BC4JToystore design (MVC) where it seperates each layer into different project. Here is the problem. 1. when i create a new Struts base JSP (JSP + Action Class) from the wizard on the controller pr