How to compile a java file which is in memory?

how to compile a java file which is in memory?
such as:
String s="class MyClass {....}";
how to compile the string?
thx

come on ...That was a perfectly valid solution.
Do you know how to call the sun.* compiler? If not then search the forums for it. If that interface still exists (which it might not in newer versions) you then will create a string stream from your class and pass it to that.

Similar Messages

  • How to compile a java file Dynamically !!!!

    Hi all
    The problem is
    I have a dynamically created java file ,and i want to compile that file dynamically itself. The file name is stored in a string,
    I am using ECLIPSE editor..
    How do i compile this java file (which is stored in a string) dynamically?
    Pls help me, already wasted a lot of time,
    Thanks in advance

    In every Tutorial regarding Dynamic Compilation,
    It is told to import javax.tools.*..
    But i cannot find this package
    I am using jdk1.4, is this the reason?
    Actually the following packages are needed fro this
    import javax.tools.DiagnosticCollector;
    import javax.tools.JavaCompiler;
    import javax.tools.JavaFileObject;
    import javax.tools.StandardJavaFileManager;
    import javax.tools.ToolProvider;
    but i cant finad any..!!!
    Please help me

  • How to compile a java file in J9 for windows mobile 5.0

    I have downloaded J9 for windows mobile 5.0 and need help on how to compile a java file.

    You can compile your source code using J2SE ;)
    may be this is important for you:
    http://awareness.ics.uci.edu/~rsilvafi/pocketPC/index.
    html
    Regards!!!Actually i am using some eSWT related classes also.. so is there any way to compile from the J9 environment using J9 console..

  • How to compile a java file(Servlet) in J2EE v1.3.1

    This is my first time using J2EE instead of J2SE!!HOw to compile a java file in J2ee\bin because there is no javac in j2ee and when i compile in J2se i got
    G:\j2sdk1.4.1_01\bin>javac HelloServlet.java
    HelloServlet.java:2: package javax.servlet does not exist
    import javax.servlet.*;
    This mean it doen;t support servlet in J2se!!so how can /what command to compile a servlet java file in j2ee.Thanks

    You'll need to add the j2ee.jar to your classpath. Usually you'll have to add some jars from your app server to your classpath as well.
    For example (using weblogic):
    javac -classpath c:\java\j2ee\j2ee1.3.1\lib\j2ee.jar;c:\tools\appserver\weblogic\wl7.1\lib\weblogic.jar
    HelloServlet.java

  • How to compile a Java file

    Hi All,
    I am extending a seeded CO and when I try to compile it in JDev , it asks for many class files the seeded CO imports.
    I have copied all those imported files to my local system and when I try to compile , it still throws an error that some class files used by the classes imported in seeded CO are missing. Now this goes on and on. ( Seems entire server needs to be on my local system).
    Now I decided to port the custom CO to server and compile it there. Even this seems to be a hard task for me as the javac command is not working on the server. It throws following exception
    Exception in thread "main" java.lang.ClassFormatError: com.sun.tools.javac.main. Main (erroneous method access flags)......................................
    Pls suggest how to compile a java file , as downloading entire server classes is a herculean task for me.
    Thanks,
    Srikanth

    Hi Avajain & D.Ram ,
    Thanks for the reply.
    I have downloaded around 70 dependent class files to local system. Now the CO is getting compiled correctly.
    I am extending a region level controller in Payroll page where in I have to default the salary to a predefined value.
    This field is having a VO attribute to it. Now can I go ahead and set a value to the MessageTextInput or should I extend the VO to replace the desired value in the place of already queried value.
    Thanks,
    Srikanth

  • How to compile a java file in a java program

    Hi,
    I don't know to compile a java file in a java class.
    Could somebody help me?
    Thanks.

    if ur using windows...
    goto ur directory and then type
    javac FILENAME.java
    and ur done!

  • How to compile other java files and run them from my own programs?

    I'm developing a unit testing tool for AspectJ, which can originally generate the stubs for aspect unit to be tested. All these stubs are java files. After generation of stubs, how can I program the code to compile this unit together with these stubs, i.e. how can I put the functionality of compilation and run, e.g. command "javac *.java" and "java *", into my own code.
    Hope you can understand what I mean.
    Thank you in advance.

    When I use Runtime.getRuntime().exec(command) for executing the AspectJ compile command "ajc", "IOException createProcess error=2" always occurs, while it is ok for Java comiple command "javac".
    Why this happens when I use Runtime.getRuntime().exec("ajc Hello.java Test.aj")? Is it the reason that Runtime.exec(String) may not support any command in DOS?
    (ajc is the compile command for the java file and aj file.)
    Thank you in advance.

  • How to Compile Servlet Java Files

    hello ...
    i am a beginner at JSPs and java servlets ... i have been searchin' hopelessly for the past couple of days. Could someone please guide me on how to compile source files for servlets ... namely how can i include the packages javax.servlet.* since the compiler gives me an error that there is no class name ... I am using jdk1.3
    Do I need to get the java server development kit ... but i cant seem to find it any where on the sun's site ... and do i need to download the j2ee sdk too ...
    As you can gather that i am completely comfused and lost ... After doing programmin with asps and previous java experience, i had thought that the migration to a java platform on would be a breeze but the lack of any solid documentation which addresses the above questions is dampenin my spirits ... and the cryptic documentation with tomcat doesnt help either. :)
    pleaze reply soon ... i have to implement a project for my company ... otherwise i would have to put servlets and jsp back in the closet and return back to asp.

    Try http://java.sun.com/j2ee/docs.html specifically, the links on that page called Download Instructions, Installation Instructions, Java Servlets Tutorial and JavaServer Pages QuickStart Guide
    By the way, J2EE SDK's reference implementation is based on Tomcat itself but is more than a web container.

  • HOW TO INSTALL JDK1.4 ON LINUX PALTFORM AND HOW TO COMPILE A JAVA  FILE

    SIR PLZ KINDLY TELL ME THE PROCDURE OF INSTALL JSDK1.4 ON LINUX .
    1.I HAVE DOWNLOADED IT ONA I HAVE INSTALL IN
    /usr/local
    but
    2: do nt know how set the CALSSPATH and JAVA_HOME(ENV VARIABLES)
    3:HOW TO COMPILE AND RUN THE JAVA FILE(JSP)

    2.
    export JAVA_HOME=/usr/local/jdk1.4.0
    export CLASSPATH=.
    (amending for your set up.)
    Placing these in your /etc/profile file will make them run automatically on log in of a user.
    3.
    You need tomcat, probably, http://jakarta.apache.org.
    Bhav

  • How to compile this java files ?

    I have two files Foo.java & Foo2.java in separate packages.
    PLEASE let me know how to compile these files .
    package XYZ;
    public class Foo {   
    public static void main(String[] args) {    }
    package XYZ.ABCD;
    class Foo2 extends Foo{
    public static void main(String[] args) {     }
                                               }I'm getting .. following error.
    XYZ\ABCD\Foo2.java:3: cannot find symbol
    symbol: class Foo
    class Foo2 extends Foo{
    ^
    1 error

    You need an import statement in Foo2.java.
    import XYZ.Foo;This should come before the package statement.

  • How to compile a java file to class with class

    There is a java file.
    And i want to compile it with class, not javac command.
    so i can catch the compile errors.
    how to do it?
    special thanks.

    http://java.sun.com/developer/JDCTechTips/2003/tt0722.html#2

  • How to compile ALL java files in OR UNDER a given directory?

    G'Day Folkies,
    At face value, TikeSwing looks like the money shot for enforcing MVC in my version of minesweeper http://forum.java.sun.com/thread.jspa?forumID=54&threadID=5248903
    I'm attempting to build the "Hello World" example which comes with TikeSwing.
    http://www.javaworld.com/javaworld/jw-06-2005/jw-0620-tikeswing.html
    It compiles ok
    C:\Java\lib\tikeswing-1.5\example\src\fi\mmm\hello>javac -d C:\Java\home\classes -cp C:\Java\lib\tikeswing-1.5\src;C:\Java\lib\tikes
    wing-1.5\lib\commons-beanutils.jar;C:\Java\lib\tikeswing-1.5\lib\commons-lang-2.0.jar;C:\Java\lib\tikeswing-1.5\lib\commons-logging.
    jar;C:\Java\lib\tikeswing-1.5\lib\log4j.jar;C:\Java\lib\tikeswing-1.5\example\src;. HelloApplication.java
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    But it doesn't run
    I presume that javac isn't detecting all dependancies, presumably because Tike "decouples M from V from C" using reflections.
    C:\Java\lib\tikeswing-1.5\example\src\fi\mmm\hello>java -cp C:\Java\home\classes;C:\Java\lib\tikeswing-1.5\lib\commons-beanutils.jar
    ;C:\Java\lib\tikeswing-1.5\lib\commons-lang-2.0.jar;C:\Java\lib\tikeswing-1.5\lib\commons-logging.jar;C:\Java\lib\tikeswing-1.5\lib\
    log4j.jar;C:\Java\lib\tikeswing-1.5\example\src;C:\Java\lib\tikeswing-1.5\src;. fi.mmm.hello.HelloApplication
    Exception in thread "main" java.lang.NoClassDefFoundError: fi/mmm/yhteinen/swing/core/component/YFrame
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at fi.mmm.hello.HelloController.<init>(HelloController.java:8)
            at fi.mmm.hello.HelloApplication.main(HelloApplication.java:8)So, Please, is there a way of telling javac to just build *.java in or under C:\Java\lib\tikeswing-1.5\src\ ... regardless of dependencies?
    Thanking You for any thoughts. Keith.

    FYI.... Here's the quick and dirty, slower than a wet week, ugly, but effective batch script
    set TIKE=C:\Java\lib\tikeswing-1.5
    set SRC=%TIKE%\src
    set LIB=%TIKE%\lib
    set CLASSPATH=%LIB%\commons-beanutils.jar;%LIB%\commons-lang-2.0.jar;%LIB%\commons-logging.jar;%LIB%\log4j.jar;.
    FOR /R %SRC% %%f IN (*.java) DO javac -d C:\Java\home\classes -cp %CLASSPATH% %%f
    @ECHO OFF
    REM http://www.robvanderwoude.com/ntfor.html
    REM Walks the directory tree rooted at [drive:]path, executing the FOR statement
    REM in each directory of the tree. If no directory specification is specified
    REM after /R then the current directory is assumed. If set is just a single
    REM period (.) character then it will just enumerate the directory tree.I can't figure out how do the equivalent of javac `dir /s /b *.java` (ie: cmd doesn't seem to have a built-in facility for expanding the results of a command into the command line) which would be a lot quicker and cleaner.
    Cheers all. Thanx for the help. I appreciate it.

  • How to compile a java file with specified jdk version in a program???

    hi,
    if we want to compile a program in another program with a particular
    jdk version as an option, how to do that,plz reply and with example.

    Hi,
    To compile from a program, read this (I've never tried, but I think it
    will work):
    http://java.sun.com/j2se/1.4.1/docs/api/java/lang/Compiler.html
    To get the jre version:
    System.getProperty("java.version");
    To get the vm version:
    System.getProperty("java.vm.version");
    Other properties at:
    http://java.sun.com/j2se/1.4.1/docs/api/java/lang/System.html
    Hope it helps,
    ANeto

  • Applet.java file which used to compile, now does not

    I cannot re-compile a java file which I used to compile many times.
    It keeps saying:
    error: cannot read PopupNavigatorApplet.java
    1 error
    I extracted the original from the archive - the same result
    What might be wrong?

    Perhaps you don't have the rights to access the file in the filesystem? Are you working on *nix or Windoze (or any other)? Is your classpath set properly (including the current working directory '.')?
    So many questions and no answers.. ;o)
    cheers,
    kelysar

  • Error IFS 20010 while compiling the java files

    Hello Friends,
    The error "IFS 20010 - Failed to get PropertyResorceBundler".....
    This error is generating while compiling the java files which will connect to the iFS with the username, password and the servicename. this error points to the servicename not found.
    I will be very greatfull for any hits or help.....

    Samir,
    You must include $ORACLE_HOME/ifs1.1/settings in you classpath.
    Thank You
    Brian Ball
    null

Maybe you are looking for

  • DNS timeout and Name Server timeout between two DC's

    Hi All My clients have a brand new domain built for them, with two domain controllers at separate sites, and one site is having some issues. At one site (where DC2 is hosted), all users are having 5-10 minute log on delays - once in everything is run

  • I need someone that is very good with computers and thinks they can help me

    im having alot of trouble with my i touch.. i have an xp computer UBS 2.. my itunes works.. the first time i opened my i touch it was completly dead. i charged it until it was completly charged,and now there is a screen that has a picture of the conn

  • How to created sales order through xi in CRM...?

    Hi My scenario is like this I have one purchase order web application. when i click submit request will go to xi throgh http request. After it receiving the request xi will take the purchase order and based on the purchase order it will create a sale

  • 4th Gen iPod Touch will not restore or do anything!

    I have a iPod Touch 4th Generation 64gb.  One day, it restarted itself without input on my part.  Now, it's showing the "Connect to iTunes" screen.  When I connect it, iTunes says its found an iPod in Recovery Mode.  When I click Restore, it download

  • A Web Page Development Question

    Hi, I want to develop a web page with an image. By clicking different areas on the image, people can go to different links. There are many such areas on the image. How can I implement that? Answer or whereabout of the answer is appreciated. myao1