Jump to content

Run-time compiler!!!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
22 replies to this topic

#1
afra

afra

    Newbie

  • Members
  • PipPip
  • 10 posts
I wanted to compile a class or a code when my application is in run-time !
but I couldn't find any thing!

now I think I found it ! I'm working on it but I'm not sure enough!

I want you every body to help me!!

It says you can add method to a class or even make a new class in run-time
and compile it without need to down the application!

do you think it is really true?

it is a class in util package named Jcompiler!

util is a package in Shine that seems to be a pattern!

I found it at:

Browse Shine-Enterprise-Pattern Files on SourceForge.net

note:you should download all parts of its library !

It's a little strange for me! any body can help me?

I'll try to find out it too if I found out any thing new I'll let you know too!

#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
By reading the API it indeed looks like you can compile at runtime. I do wonder why you would need it, and i assume it isn't possible to change classes you're currently runnnig tho ;)

It probably works like:
File file = new File("MyClass.java");
File outputDir = new File("c:/some/path/to/dir");
JCompiler compiler = new JCompiler();

compiler.setTargetDir(outputDir);
compiler.compile(file);
And hopefully a .class file is created in the output directory.

#3
afra

afra

    Newbie

  • Members
  • PipPip
  • 10 posts
I want to deploy a program could change by users! you know something like an AI that could learn!

so I was interested to find some thing could help me!

yes I have think same as you but it says it can do it and it works! I'm testing if I can do a hello world! if you do too and help me I really appreciate you! It's unbelievable for me because if it's true I will catch my dream!

thanks a lot!

I'll let you know if I will successful!

#4
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
I can't compile java here on this computer. So that'll have to wait for ~4hrs :(
I do indeed wonder what would happen if you overwrite a .class file that the program uses... if it doesn't lock those.

#5
afra

afra

    Newbie

  • Members
  • PipPip
  • 10 posts
Thanks a lot I will wait impatiently! it's really your favor!

#6
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
By the way, i don't think that AI code would actually write its own code and then use the new code. AI software is based on predefined variables and uses those variables to make decisions. Dependent on the result of that decision, it will change his decision-making variables. These variables may also be named "weights".

...And that's about all i know about AI :P

#7
afra

afra

    Newbie

  • Members
  • PipPip
  • 10 posts
you're right but I am working on an advance theory that says AI should have ability to learn same as a human! so I need sth to let me compile at run-time! I think it will be closer to a real human! what do you think?

#8
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
I think it's more riscful to let a computer decide what it's going to run. Imagine this code
Disc.format("C");

It wouldn't be very fun if the AI eventually wrote and ran that :)

#9
afra

afra

    Newbie

  • Members
  • PipPip
  • 10 posts
yes but we can define some predefined rules for it to prevent it from probable mistakes too! both together! like a human when somebody learn you how to kill yourself you will never do that because it had been defined for you that makes you destroyed forever!

Its seems hard but it's really interesting for me!

#10
afra

afra

    Newbie

  • Members
  • PipPip
  • 10 posts
dear oxano

did you find anything? I'm really curious about it!

#11
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
Yea, i found that i get errors, even when i follow their tutorial.

#12
afra

afra

    Newbie

  • Members
  • PipPip
  • 10 posts
thank you !

what were your errors?