aspose file tools
The moose likes Java in General and the fly likes dynamically create a file & load it using Class.forName() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "dynamically create a file & load it using Class.forName()" Watch "dynamically create a file & load it using Class.forName()" New topic
Author

dynamically create a file & load it using Class.forName()

Vincent Goh
Greenhorn

Joined: Mar 06, 2007
Posts: 7
I'm trying to dynamically create a file in the source directory. Then load the newly created code file using Class.forName();

The problem: when the file gets created, i wasn't able to see it until I do a refresh on the project. Which means that I have to relaunch the program in order to access the code file created. That's bad!
Is there a way to create the code file then access it using Class.forName() without relaunching the program?
Feel free to try out the code below.

thanks,
vincent

-------------------------------------------------------------------------
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35240
    
    7
Aren't you missing the step where you are compiling the source file? Class.forName can only load class file, not source files. Your IDE probably compiles it when you run the program, but that is not a function of Java itself. In you want to create new classes with a running program, you need to compile them explicitly.


Android appsImageJ pluginsJava web charts
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: dynamically create a file & load it using Class.forName()
 
Similar Threads
Files
how to redirect standard in, output, err into a file?
Downloading the document
Including property file in the jar
Where the html file is created??