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?

Similar Messages

  • Batch file to execute java code

    Hi,
    I need to write a batch file to execute a sequence of java applications.
    The problem i face is in addition to the usual libraries I am also using certain jar files i downloaded like the mail interface etc.
    When i just compile a java code using a simple batch file giving the path of the compiler and the java code, it fails citing not knowing the location if the packages.
    could anyone please let me know what i need to do. Is there like a skeleton that i might find somewhere for this operation

    dexterity wrote:
    Hi,
    I need to write a batch file to execute a sequence of java applications.
    The problem i face is in addition to the usual libraries I am also using certain jar files i downloaded like the mail interface etc.
    When i just compile a java code using a simple batch file giving the path of the compiler and the java code, it fails citing not knowing the location if the packages.
    could anyone please let me know what i need to do. Is there like a skeleton that i might find somewhere for this operationSet the classpath correctly at runtime.
    Why do you need the location of your compiler? Are you compiling or running? If you are compiling go look at Ant.

  • Compile a Java code to a native machine code

    Hi Everyone,
    What tool do I need to compile a Java code to a native machine code? Is there any free tool?
    Cecilia

    google.com is a good place to start

  • Execute Java Code on client

    Hello,
    how can i execute java code on clientside?

    I guess you will have to add an applet to the web page.
    http://developers.sun.com/prodtech/javatools/jscreator/reference/techart/2/applet.html

  • Java.lang.NoClassDefFoundError when executing JAVA code

    Hy everyone,
    Trying to execute some java code through forms I got this error when running my program : java.lang.NoClassDefFoundError : simple (where simple is a java class I developped).
    These are the steps I followed:
    1- Devopping a simple JAVA class (simple.java) and compiling in JDK 1.4 (for compatibilty with forms 10.1.2.0.2)
    2- Creating the JAR file
    3- Copying the JAR file in <ORACLE_HOME>\forms\java
    4- Adding the adress of the JAR file in CLASSPATH (environment variable of the server)
    5- Adding the adress of the JAR file in CLASSPATH (environmental file of OAS default.env)
    6- Importing the JAVA class trought forms builder (program>>import java class)
    7- Invoking the JAVA class via the PL/SQL packages created by forms builder
    8- Running the program
    Thanks for your help.
    Regards.

    In most cases, you should not have to stop and restart OC4J_BI_FORMS to pick such changes. However, since you are having problems, I would ensure that all frmweb processes have been stopped, then stop and restart OC4J_BI_FORMS and retest. If that doesn't work, you should review how you imported the java into your app. Look closely at the Importer options you used and ensure that you have not change the file name at any point. Because you are working with Java, case sensitivity is critical.
    Also, where are you seeing the error message? Client java console or in a server side log? If server side, exactly which log file is reporting the problem? I would suggest you post the first 4 ro 5 lines of the error and not just the NoClassDefFound part.

  • Error when executing Java code, java.lang.NoClassFoundError:

    Hi, I am new learner in Java Programming and I am using J2SDK and notepad to write a code. I don't have problem in compiling using javac filename, however I received an error when executing using java filename.
    The error message I got is Exception in thread "main" java.lang.NoClassDefFoundError: Hello/jawa.
    I have verified this simple code - Hello has no issue but somehow it does not run. I even try to compile and execute in other computer also the similiar error returned.
    My Client Platform is Windows XP Professional.
    I would appreciate any expert can help to suggest me the knowledge/solution to fix this kind of error. Thanks
    Jackie

    It looks like you entered the command "java Hello.java" or "java Hello/java" (I assumed 'jawa' was a typo.)
    You should have entered "java Hello" if your class name is Hello. I am guessing that Hello.java is probably the source code file name. The argument to the java command is the fully qualified class name. "java Hello.java" tells the java command to look for a class named java that is in the Hello package.

  • Convert strings to executable java code

    Hey,
    I'm not sure how easy or hard this is to accomplish, but I am looking for a way to take a string from a JTextField and use it as a control structure for an IF block.
    For example, the user inputs 'keyword=="test" || keyword=="test2"' I want to use it in an if block to control it.
    Is there a way to do this? I realize the java file is already compiled in a class, so the string would probably be incapable of doing such a thing.
    Any thoughts would be appreciated!

    Basically this is impossible, because Java is a compiled language, but there are ways around it.
    Actually the ways are all basically one way: use an interpreted language. You can embed one into Java. You can write your own, new language (it could be a small simple mini-language, for example one that only evaluates boolean expressions; this is easier than it sounds), or you can use one that already exists.
    There already is an interpreted language for Java. It's called BeanShell. Also I'm told that someone has written a javascript interpreter for Java, but I don't know the details.
    I'd suggest Googling for BeanShell. It sounds like the quickest, easiest solution.
    But be careful: letting users execute arbitrary code can be a huge security hole.

  • Running the .class file from java code

    I'm doing a kind of providing service like compiling and running Java code on server side and giving output to the end user.
    Please suggest me an approach with code to run .class file from the Java code.
    import java.io.*;
    public class demo {
    public static void main(String args[]) throws IOException, InterruptedException {
    int result;
    try {
    System.out.println("command output:");
    Process proc = Runtime.getRuntime().exec("java -cp . demoh");
    InputStream in = proc.getInputStream();
    result = proc.waitFor();
    BufferedInputStream buffer = new BufferedInputStream(proc.getInputStream());
    BufferedReader commandOutput = new BufferedReader(new InputStreamReader(buffer));
    String line = null;
    System.out.print(commandOutput);
    try {
    while ((line = commandOutput.readLine()) != null) {
    System.out.print(line);
    System.out.println("command output: " + line);
    }//end while
    commandOutput.close();
    } catch (IOException e) {
    //log and/or handle it
    }//end catc
    } catch (IOException e) {
    System.err.println("IOException raised: " + e.getMessage());
    }

    What happened when you tried what you have there?

  • Execute java code before rendering the page

    Hi,
    In a task flow, can I execute some java code before the page/view is rendered (i.e. some preprocessing). I would need to be able to have access to the bindings on the page.
    Thanks!

    Can you try doing as specified below:
    If it is simple JSPX, you could use the phase listener as follows:
    JSPX Code:
    <f:view beforePhase="#{SamplePageBean.phaseListener}">
    <af:document id="d1">
    <af:form id="f1">
    <af:panelFormLayout id="pfl1">
    <f:facet name="footer"/>
    </af:panelFormLayout>
    </af:form>
    </af:document>
    </f:view>
    Bean Code:
    public class SamplePageBean {
    public SamplePageBean() {
    public void phaseListener(PhaseEvent phaseEvent) {
    if (phaseEvent.getPhaseId().equals(phaseEvent.getPhaseId().RENDER_RESPONSE)) {
    // DO NECESSARY INITIALIZATION
    Thanks,
    Navaneeth

  • Executing Java Code in ODI Procedure

    Hi All,
    I have following  java code which i need to write on ODI procedure but i am not sure which technology to chose (Jython,Sunopsis API or Java BeanShell).
    I tried to execute the procedure Jyhton with <% "Java code"%> but getting the error.Any boddy can suggest where i doing wrong.
    <%
    import javax.naming.Context;
    import javax.naming.NamingEnumeration;
    import javax.naming.directory.*;
    import java.util.Hashtable;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    String userName = "HXXXXXX";
    String CN1=null;
    String Dis_Name=null;
    String Mem_of=null;
    String Mail=null;
    String SGID=null;
    File file = new File("C:/Project/ODI/LDAPID.txt");
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "LDAP://XX.if.YYYY.net:389/OU=XYZ,DC=ZZ,DC=if,DC=XYZ,DC=COM");
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put(Context.SECURITY_PRINCIPAL, new String("" + "\\" + userName));
    env.put(Context.SECURITY_CREDENTIALS, "");
    DirContext ctx = null;
    NamingEnumeration results = null;
    ctx = new InitialDirContext(env);
    SearchControls controls = new SearchControls();
    controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
    results = ctx.search("", "(objectclass=person)", controls);
    FileWriter fw = new FileWriter(file.getAbsoluteFile());
    BufferedWriter bw = new BufferedWriter(fw);
       while (results.hasMore())
             SearchResult searchResult = (SearchResult) results.next();
             Attributes attributes = searchResult.getAttributes();
             Attribute attr = attributes.get("cn");
             String cn = (String) attr.get();
             CN1=(String.valueOf(attributes.get("cn")));
             Dis_Name=(String.valueOf(attributes.get("displayName")));
             SGID=(String.valueOf(attributes.get("userPrincipalName")));
             Mem_of=(String.valueOf(attributes.get("memberOf")));
             Mail=(String.valueOf(attributes.get("mail")));
             bw.write(CN1 + " || " + Dis_Name + " || " + SGID + " || " + Mail);
             bw.newLine();
    bw.close();
    results.close();
    ctx.close();
    %>
    I am getting following error.
    The application script threw an exception: java.lang.NullPointerException BSF info: CODE_JAVA at line: 0 column: columnNo
    Please suggest what went wrong with the code.
    Thanks
    Regards

    In Jython you don not need to declare the type so String userName = "HXXXXXX"; should simply read userName = "HXXXXXX" . Lots of your code need to be rewritten to work with Jython if you choose that as your technology.

  • Execute java code taken from a properties file

    I have a requirement to store some java code in the Properties file & use the code inside the program later. Is there a way I can execute this code after I get it from the .properties file which is retrieved using the ResourceBundle?
    Example:
    File: system.properties
    Item_list=blocksBean.menu(QueryValue,request.getContextPath())
    Inside my Java program I'm using this..
    theBody=codesBean.replaceAll(theBody, "%%menu%%",ResourceBundle.getBundle("system").getString("Item_list"), true);
    instead of
    theBody=codesBean.replaceAll(theBody, "%%menu%%",blocksBean.menu(QueryValue,request.getContextPath()), true);
    This doesn't work because ResourceBundle.getBundle("... returns the value.. which is a string "blocksBean.menu(QueryValue,request.getContextPath())". But what I need is it has to be executed..
    blocksBean.menu() returns a string value of html code fetched from the dartabase.
    Is there a way I can execute blocksBean.menu() which is retrieved from the .properties file.. If anyone has done it / have an idea on this.. please e-mail me [email protected]
    I need something like an eval() in javaScript..
    Thanks in advance
    -ashok

    These boys might have something that will help you:
    http://www.beanshell.org/
    Good luck
    Lee

  • Execute Java code after login

    Hi experts,
    I'd like to execute some Java code after a successful login. I guess I could write a custom login module or use a WD Java iView to do this but a "better" solution may exist.
    Regards,
    Pierre

    Customizing your login module is probably your best bet. As soon as you're user is authenticated, you can execute your custom Java code.
    From my experience, I have not seen an easier / cleaner way to capture that event.
    Regards,
    Tom

  • Using a button of type=button to execute java code

    Hello,
    I here what I need to do.
    - A user fill a form
    - He press submit
    - the button goes and execute some java code and then refresh the page (same page)
    Now I don't want to use a input=Submit, that call a a servlet that just update the information, and output to the servlet;
         out.println("<html>");
          out.println("<body>");
          out.println("<head>");
          out.println("<meta content=\"1; url=" + "SamePage.jsp" + "\" http-equiv=refresh>");
          out.println("</head>");
          out.println("</body>");
          out.println("</html>");Instead, I would like to do: <INPUT TYPE="button" VALUE="Close Window"   onClick="window.close();"> but instead of JavaScript in the onClick it would be JavaCode that would update the object (already instantiated in the JSP) and would then refresh the page.
    Is this possible?
    thanks.

    Hi,
    it is not possible because JSP code is executed server-side, while javascript code is executed client-side (in client's browser).

  • How to compile the java code into machine execution code?

    Does anyone can tell me how to compile java code into machine execution code on specific OS platform such as Windows2000 , UNIX �Ketc.
    Thanks a lot !

    Hi SIR
    It is very kind of you to give me so great informatin!
    Thanks a lot!
    Caton

  • Error when compiling multiple java code files

    Hi,
    Since I installed J2SDK downloaded from this website, it has never compiled my code correctly when written in multiple java files. Below is a sample of my code and the error message I am getting:
    File#1
    class testprint{
    public static void main(String args[]){
         myprint mp = new myprint();
         mp.manageprint();
    File#2
    class myprint{
    void manageprint(){
         System.out.print("please print");
    Here is my error message from the command line:
    c:\print>javac testprint.java
    testprint.java:4: cannot resolve symbol
    symbol : class myprint
    location: class testprint
         myprint mp = new myprint();
    ^
    testprint.java:4: cannot resolve symbol
    symbol : class myprint
    location: class testprint
         myprint my = new myprint();
                   ^
    2 errors
    C:\
    It seems Java is not recognizing myprint.java file. Do I need to configure anything to make my code work? Please help!
    Thanks in advance.

    Are both files in the same directory? Is the directory in your classpath?

Maybe you are looking for