Compiling / virtual files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Compiling / virtual files

jespersahner
Hi!

Inside NetBeans is it possible to compile against virtual files rather than
physical .java-files?

The "system filesystem" is a virtual filesystem, so I think maybe .java- and
.class-files could be represented in the same way inside NetBeans (?)

Regards,
Jesper


Reply | Threaded
Open this post in threaded view
|

Re: Compiling / virtual files

Brian Cook

This is probably just my ignorance here.  But why would you ever want to
do that?  Even if you could get it to build it will likely fail at run
time since it is going to throw a class not found exception.

If you knew the structure of the actual .java file you could create a
dummy class with all the same method calls and just leave them all
empty.  That way the class would be there for the complier to see to
link it to.  I am guessing this will not work for what ever it is you
need to do though.


jesper sahner wrote:

> Hi!
>
> Inside NetBeans is it possible to compile against virtual files rather
> than physical .java-files?
>
> The "system filesystem" is a virtual filesystem, so I think maybe .java-
> and .class-files could be represented in the same way inside NetBeans (?)
>
> Regards,
> Jesper
>
>
>

--
Brian Cook
Digital Services Analyst
Print Time Inc.
[hidden email]
913.345.8900
Reply | Threaded
Open this post in threaded view
|

Re: Compiling / virtual files

jespersahner
Hi Brian!

Accessing the Java compiler programmatically is a fundamental feature - like
reflection - in some applications. Have a look at
http://www.jcp.org/en/jsr/detail?id=199

Until this API is released the javac-compiler can be accessed using e.g.
Runtime.getRuntime().exec("javac..."). However the "problem" is, that javac
works on a physical filesystem with physical .java- and .class-files. The
problem being speed and maybe protecting your code.

A workaround until the Java Compiler API is released would be to emulate the
filesystem as a "virtual" filesystem that javac could use.

Maybe this can be achieved using RAMDisk which does exactly this (see e.g.
http://www.cenatek.com/product_ramdisk.cfm and
http://www.superspeed.com/ramdisk.html
). I don't know if/how this will work with javac (?)

However a more elegant solution would be to emulate a physical filesystem as
a virtual filesystem inside Java/NetBeans until the Java Compiler API comes
around.

I wonder if this is possible?

Regards,
Jesper

>From: Brian Cook <[hidden email]>
>Reply-To: [hidden email]
>To: [hidden email]
>Subject: Re: [nbusers] Compiling / virtual files
>Date: Tue, 16 Aug 2005 10:23:38 -0500
>
>
>This is probably just my ignorance here.  But why would you ever want to do
>that?  Even if you could get it to build it will likely fail at run time
>since it is going to throw a class not found exception.
>
>If you knew the structure of the actual .java file you could create a dummy
>class with all the same method calls and just leave them all empty.  That
>way the class would be there for the complier to see to link it to.  I am
>guessing this will not work for what ever it is you need to do though.
>
>
>jesper sahner wrote:
>>Hi!
>>
>>Inside NetBeans is it possible to compile against virtual files rather
>>than physical .java-files?
>>
>>The "system filesystem" is a virtual filesystem, so I think maybe .java-
>>and .class-files could be represented in the same way inside NetBeans (?)
>>
>>Regards,
>>Jesper
>>
>>
>>
>
>
>--
>Brian Cook
>Digital Services Analyst
>Print Time Inc.
>[hidden email]
>913.345.8900