Just started learning Java...

Started by
22 comments, last by Kambiz 17 years, 11 months ago
Java doesn't have anything standardized akin to CodeDom and I'm somewhat unsure as to wether it is technically possible to implement something similar in a JVM. You could certainly load another class in another thread, but reloading code in the same thread is going to be harder, I believe.

Google is your friend I guess.
I teleported home one night; With Ron and Sid and Meg; Ron stole Meggie's heart away; And I got Sydney's leg. <> I'm blogging, emo style
Advertisement
Quote:Original post by jfclavette
Java doesn't have anything standardized akin to CodeDom ...


You know, it would be really helpful if you all said what you plan to do instead of using some "MS patented terminology (tm)". WTF is CodeDom!? Will I need a dictionary to translate what you are saying?

Sorry, Java developers can't help you if they can't understand what you want.
Quote:Original post by Anonymous Poster
Quote:Original post by jfclavette
Java doesn't have anything standardized akin to CodeDom ...


You know, it would be really helpful if you all said what you plan to do instead of using some "MS patented terminology (tm)". WTF is CodeDom!? Will I need a dictionary to translate what you are saying?

Sorry, Java developers can't help you if they can't understand what you want.


Compiling a .java file at runtime, loading the class and instantiating it. This is only a microscopic subset of what CodeDom can do, but I assume it's what the OP wants to do. It's also a significant enough building block to start building CodeDom-like functionnality in Java.

I tought 'Java developers' (somehow tying a language to the word programmers seems so pathetic to me) could use Google.

[Edited by - jfclavette on May 17, 2006 4:13:21 PM]
I teleported home one night; With Ron and Sid and Meg; Ron stole Meggie's heart away; And I got Sydney's leg. <> I'm blogging, emo style
Quote:Original post by jfclavette
Compiling a .java file at runtime, loading the class and instantiating it. This is only a microscopic subset of what CodeDom can do, but I assume it's what the OP wants to do. I tought 'Java developers' (somehow tying a language to the word programmers seems so pathetic to me) could use Google.


Google returned nothing but a bunch of gibberish. I thought '.Net developers' were could use complete meaningful sentences, is that difficult?

BTW, it's possible to mess with classloaders in Java, dynamically instantiate classes, use external scripting languages (from the 6 it will be in the standard JDK), etc, but I will leave that for you to look up on Google, ok?

Good search.
Quote:Original post by Anonymous Poster
Quote:Original post by jfclavette
Compiling a .java file at runtime, loading the class and instantiating it. This is only a microscopic subset of what CodeDom can do, but I assume it's what the OP wants to do. I tought 'Java developers' (somehow tying a language to the word programmers seems so pathetic to me) could use Google.


Google returned nothing but a bunch of gibberish. I thought '.Net developers' were could use complete meaningful sentences, is that difficult?

BTW, it's possible to mess with classloaders in Java, dynamically instantiate classes, use external scripting languages (from the 6 it will be in the standard JDK), etc, but I will leave that for you to look up on Google, ok?

Good search.


I know it's possible to load from a JAR. What I'm interested in is compiling them without resorting to external tools and in a way where I can assume anyone with any JVM can do the same. Does Java maintain a reliable accessible path to the compiler (is the compiler included in the JVM ?) that is guaranteed to work in all case on any machine ? I'd be fine with that, even if it wouldn't offer the synctactic sugar .NET offers.

I would also like to load binaries from languages other than Java. I don't want to use an arbitrary interpreted scripting language, but say, C++ or C#. (Altough .NET requires a third-party library to load Java classes, the underlying used functionnality is CodeDOM, so loading C# classes in Java wouldn't be as easy, and as such, no popular projects doing so exist.)
I teleported home one night; With Ron and Sid and Meg; Ron stole Meggie's heart away; And I got Sydney's leg. <> I'm blogging, emo style
I know *exactly* what I want:
My application will have a small kernel, the kernel will load many PlugIns, compile them and use them when needed. In Managed C++ or C# I would use C# like a scripting language and compile all the PlugIns using the CodeDomProvider, now I want to know if it is possible to do the same thing in Java.
Please do not tell me I need to use a scripting language! If that is the only way in Java I will use c# for this Project at the cost of portability.
Quote:Original post by Kambiz
I know *exactly* what I want:
My application will have a small kernel, the kernel will load many PlugIns, compile them and use them when needed. In Managed C++ or C# I would use C# like a scripting language and compile all the PlugIns using the CodeDomProvider, now I want to know if it is possible to do the same thing in Java.


AFAIK the java compiler is only available to those with the sdk, not the java runtime. Java can load and use arbitrary class files during execution (not only those included during compilation ), and can load DLLs ( but you need some special interfacing to talk to the JVM, namely the JNI ).

If I read the MSDN page here correctly:
Quote:
. Several languages are supported by CodeDomProvider implementations that ship with the .NET Framework SDK.


Does this mean that an implementation of CodeDom only exists if you have a .Net SDK installed? Or idoes the SDK come with the runtime?


However, anyone who is going to be writing plugins for your program will surely have access to a compiler, so why would it be neccesary to have your program compile the .javas as opposed to just using the .class / .jar files?
Quote:Original post by rip-off
Quote:Original post by Kambiz
I know *exactly* what I want:
My application will have a small kernel, the kernel will load many PlugIns, compile them and use them when needed. In Managed C++ or C# I would use C# like a scripting language and compile all the PlugIns using the CodeDomProvider, now I want to know if it is possible to do the same thing in Java.


AFAIK the java compiler is only available to those with the sdk, not the java runtime. Java can load and use arbitrary class files during execution (not only those included during compilation ), and can load DLLs ( but you need some special interfacing to talk to the JVM, namely the JNI ).

If I read the MSDN page here correctly:
Quote:
. Several languages are supported by CodeDomProvider implementations that ship with the .NET Framework SDK.


Does this mean that an implementation of CodeDom only exists if you have a .Net SDK installed? Or idoes the SDK come with the runtime?


However, anyone whoe is going to be writing plugins for your program will surely have access to a compiler, so why would it be neccesary to have your program compile the .javas as opposed to just using the .class / .jar files?


The compilers, not the SDK, come with the Framework redistributable. As to why, say I want the users to be able to script my game trough a level editor. The scripting language I want is a subset of C#. They script the game trough my level editor, save, load the game, and their modifications take effect automatically.
I teleported home one night; With Ron and Sid and Meg; Ron stole Meggie's heart away; And I got Sydney's leg. <> I'm blogging, emo style
Quote:Original post by jfclavette
I know it's possible to load from a JAR. What I'm interested in is compiling them without resorting to external tools and in a way where I can assume anyone with any JVM can do the same. Does Java maintain a reliable accessible path to the compiler (is the compiler included in the JVM ?) that is guaranteed to work in all case on any machine ? I'd be fine with that, even if it wouldn't offer the synctactic sugar .NET offers.


See Java 6 Mustang releases for the Compiler API. Prior to that version you will to look up for libraries on the net.

Quote:
I would also like to load binaries from languages other than Java. I don't want to use an arbitrary interpreted scripting language, but say, C++ or C#. (Altough .NET requires a third-party library to load Java classes, the underlying used functionnality is CodeDOM, so loading C# classes in Java wouldn't be as easy, and as such, no popular projects doing so exist.)



Anything else? Maybe a cup of coffee? Listen, you don't expect to produce decent production code in C++ for running in the JVM, do you?

So basically you are asking for some idiotic stuff that shouldn't be done nor attempted? If you need to use C++ then use C++, if you need C# then use C#.

Don't even come with J# as an example of Java for .Net, that's based in a very old version of Java that Microsoft had but was sued by Sun for having "incompatibilities".

There's the Java 6 Mustang scripting language support. Prior to that there was a framework for adding such languages to Java at Apache website that's not locked to a specific language.

Have a nice day.
Quote:Original post by Anonymous Poster
Anything else? Maybe a cup of coffee? Listen, you don't expect to produce decent production code in C++ for running in the JVM, do you?


Yes. It works in .NET.

Quote:
So basically you are asking for some idiotic stuff that shouldn't be done nor attempted? If you need to use C++ then use C++, if you need C# then use C#.


I've written my whole game server in C++. I want to write the client in Java while reusing the common classes I need. Isn't that valid ?

Quote:
Don't even come with J# as an example of Java for .Net, that's based in a very old version of Java that Microsoft had but was sued by Sun for having "incompatibilities".


I wasn't talking about J# but about the flurry of Open Source or proprietary hooks to compile and run Java code for .NET.

Quote:
There's the Java 6 Mustang scripting language support. Prior to that there was a framework for adding such languages to Java at Apache website that's not locked to a specific language.


I wasn't aware of that. Why is it so underused compared to similar .NET functionnality ? I see tons of .NET hooks for languages such as FORTRAN, COBOL and friends, yet nothing for Java.
I teleported home one night; With Ron and Sid and Meg; Ron stole Meggie's heart away; And I got Sydney's leg. <> I'm blogging, emo style

This topic is closed to new replies.

Advertisement