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
Similar Messages
-
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?
thxcome 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. -
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.ThanksYou'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 -
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,
SrikanthHi 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 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 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 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 errorYou 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 -
Compiling one java file within another java program
Hi all,
I want to compile one java file say one.java within a java program say second.java.. i simply have no idea as how to proceed ..pls help!!http://onesearch.sun.com/search/onesearch/index.jsp?qt=dynamically+compile&subCat=siteforumid%3Ajava31&site=dev&dftab=siteforumid%3Ajava31&chooseCat=javaall&col=developer-forums
Just to give you an idea. -
Hi Everybody,
I have a serious problem. I want to compile a Java file withing another Java program, without using the "javac" command or this compiler. Is there any function or class which helps compile a Java source file created withing another Java Class file, So that the new Java source file will not be available to the outside world?
Thanks,
TechnoSam.I'm pretty sure that you can create a class in memory by passing it a stream of bytecode. From this you could create a new instance and then proceed as normal. However, you're going to need to know how to create that bytecode and I guess that you don't want to have to implement a 'virtual' compiler from scratch. I don't know of anything that can do this for you but I wouldn't be surprised to find that somebody's had a go in the past.
Perhaps your requirements would be satisfied by compiling your dynamically created source using javac to a temp file and then deleting that once you had instantiated the object? This would do something like what I think that you're after but even then you would need to accept that others would be able to access your class definition by reverse-engineering your source-writing routine, (whether or not it was obsufacated).
Can you say anymore about what you're trying to achieve?
Maybe you are looking for
-
Hi I want to have the "Edit in place" functionality in an ALV. Do you have an URL or example of how to do this? Thanx in advance
-
Internal Order Settlement-urgent
Hi Gurus I have an internal order balance of -160$ USD. USD is the Controlling Area Curr. But when viewed in local Curr (CAD) it has a balance of zero. I checked the controlling area settings, and it is set to update local aswell as contr. area curr.
-
Missing icons in hotmail rich text toolbar
''locking as a duplicate - https://support.mozilla.com/en-US/questions/895602'' the icon for text highlighting does not appear in the rich text toolbar in hotmail. it does display in IE8. why has it dissappeared today.
-
Airtunes still dropping out!
I am still having trouble with my airtunes frequently dropping the signal to my speakers. When I pause the music and then start it again, it works. I have the most recent version of itunes. My computer is also very close to my airport express. What c
-
Exporting movies from Premiere Elements 4.0 to Apple TV
I've made a movie in Adobe Premiere Elements 4.0, and would like to view it on my Apple TV. I've saved the video as a quicktime MOV file, but iTunes tells me that this type of file can not be view n the TV. Any ideas?