Compiling new classes on the fly without having a .java file

Hi everybody,
I'd like to compile dynamically produced JAVA code (code from user input in my application). I don't wanna store the source code in a .java file, but just compile the code (as char[] or something like that) to a byte[].
Does anybody have an idea ??
Thanks
Jan

Have you looked at the idea of interpreting rather than compiling, say using Jython (a python interpreter written in Java). Python and Java are extremely close in syntax, and it should be relatively easy to do what you are talking about.
I am worried though, that you are going to let users type in text, and assume that it has valid syntax in the language you are using. Many years of UI experience indicate that letting users type in anything results in a certain error rate. Letting it be instructions you are to follow in your code is even more dangerous.
There are many programs that let users define actions interactively. They seem to either let the user type in text, and error check it to death (a lot of work, think spreadsheet type programs), or they present the user with a set of choices, often using a wizard type interface, which takes more up front UI work, but only lets the users select valid options.
It sounds like you want to interpret what the user types in as instructions. Even with Jython (or a similar interpreter), you would need to parse the user input for formatting errors, invalid variable names, and anything else they could make a mistake on, before you could pass any of it to the interpreter.
Good luck.

Similar Messages

  • I'm among about 140 people who received the same email. I want to include all of those addresses in a new group. Is it possible to create the group without having to manually enter each of the 140 addresses?

    I'm among about 140 people who received the same email. How can I create a new group for these people without manually entering all 140 addresses?

    Hi  SDGNOM,
    According to your description, my understanding is that you want to export  list to Excel with all columns in your SharePoint.
    For the SharePoint RPC protocol method, SharePoint export to excel will take the list id as well as the view id. So we cannot export list to Excel with all the columns without having to depend on the fields
    chosen in the default view.
    Reference:http://msdn.microsoft.com/en-us/library/ms478653.aspx
    For a workaround, you can achieve your demand via PowerShell. Here is a  template you can refer to:
    Param(
    [Parameter(Mandatory=$True)]
    [string]$webUrl,
    [Parameter(Mandatory=$True)]
    [string]$outPath
    $web = Get-SPWeb $webUrl
    write-host ("Path: " + $outPath)
    foreach($list in $web.Lists)
    $exportlist = $null
    $exportlist = @()
    $list.Items | foreach {
    $hash = $null
    $hash = @{}
    foreach($fld in $_.Fields ){
    Try {
    $hash.add($fld.Title, $_[$fld.Title])
    Catch [System.Management.Automation.MethodInvocationException]
    # Eating an error caused by duplicate column names.
    Finally
    #"End"
    write-host ("Exported: " + $_.Title)
    $obj = New-Object PSObject -Property $hash #@{
    $exportlist += $obj
    $expath = $outPath + '\' + $list.Title + '.csv'
    $exportlist | Export-Csv -path $expath #$oPath
    Reference:
    http://porchcode.blogspot.com/2013/04/exporting-sharepoint-list-items-to-csv.html
    Thanks,
    Eric
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support,
    contact [email protected]
    Eric Tao
    TechNet Community Support

  • Defining class on the fly

    Hi,
    Is it possible to have a java program read in a new class from a text file while the program is running and then compile that class file and use it?
    thanks

    inabind wrote:
    thanks. First of all I just wanted to know if it was possible. What I really want to do is define a whole bunch of methods which will act on data depending on the format of that data. So, when the web-app is deployed and running I want a user to be able to dynamically define a class/method to act on their own data. i.e.:
    data = "The brown fox is very cunning"
    method = replace every third letter with capital equivalent.
    now, this is dead easy to do in the 'solid' code but i would like to do it on the fly...Well, how did you, as a person, make that decision? The rules so far aren't clear, but you're probably looking for the Strategy design pattern
    Generating classes on the fly isn't going to be much use. You want to reuse components, not endlessly recreate them

  • I just got the mid 2011 macbook air and it does not have ilife or iPhoto on it...isnt it supposed to come with it? and if it does then how do i get it on the mac without having to pay for it in the app store?

    I just got a macbook air and i thought that it was supposed to come with ilife already installed? But there is not ilife apps...how do i get  it on the laptop without having to buy them all from the app store if it was supposed to come with it?

    From the iPhoto Licence:
    3. Transfer.
    A. Apple Software obtained from the Mac App Store is not transferable. If you sell your Apple-branded hardware to a third party, you must remove the Apple Software from the Apple-branded hardware before doing so.
    B. For any preinstalled Apple Software, you may make a one-time permanent transfer of all of your license rights to the Apple Software (in its original form as provided by Apple) to another party, provided that: the Apple Software is transferred together with your Apple-branded hardware; (ii) the transfer must include all of the Apple Software, including all its component parts, printed materials and this License; (iii) you do not retain any copies of the Apple Software, full or partial, including copies stored on a computer or other storage device; (iv) you have not associated the Apple Software with your Mac App Store account as set forth in Section 2B; and (v) the party receiving the Apple Software reads and agrees to accept the terms and conditions of this License.
    If the previous owner accepted the preinstalled software (iPhoto, etc) to the AppleID, it cannot be passed on to a new owner. Even if the previous owed would use her or his Applied to install it for you, you would never be able to reinstall it or to update it.
    In that case buy your own copies of the software.

  • How do you download a web page to a folder on the desktop without having all of the other rubish with it

    When looking on Web Sites associated with Ancestry information how can i save the information i find to a folder on my desktop without having 3/4 files with other information that i do not want / need. The information i want is shown in a second file which is great but when i delete the 3/4 files i do not want it removes the file that i do want also. I use Windows 7.

    Hi bjmw,
    What is the method you are using to download the webpage? Are your right clicking on the webpage and choosing "Save as.." or using an alternative method? The 3 or 4 files you are getting are likely the style-sheets associated with the website, without them the website would be nearly impossible to read.
    Thanks,
    Scott

  • HT5570 My six-year old grandson appears to be able to make purchases on the TV without having to enter the password and yet every other device i use (e.g. iPad, iPhone, iPod) is password protected. How is that possible?

    My six-year old grandson appears to be able to make purchases on the TV without having to enter the password and yet every other device i use (e.g. iPad, iPhone, iPod) is password protected. How is that possible when I have to use my password to access such services on all other devices?

    DominicDeBurca wrote:
    My six-year old grandson appears to be able to make purchases on the TV without having to enter the password and yet every other device i use (e.g. iPad, iPhone, iPod) is password protected. How is that possible when I have to use my password to access such services on all other devices?
    Having AppleTV remember the password is optional.
    Logout of iTunes store, log back in and hopefully next time you come to purchase you'll be prompted for your password but decline the option to remember it.  You might also want to look out of parental controls on the unit.
    AC

  • I would like to play music from my iPhone 5 on the speakers attached to my computer at work. I don't have the authority to download itunes onto the computer. Can I play the music from the phone without having itunes on the computer?

    I would like to play music from my iPhone 5 on the speakers attached to my computer at work. I don't have the authority to download itunes onto the computer. Can I play the music from the phone without having itunes on the computer?

    KiltedTim wrote:
    The cable would be much cheaper than the Scotch!
    But much less fun or satisfying.
    Signed,
    An IT guy 

  • My iPhone has my old email set up throught iCloud. How do I reset my new username with the device without deleting everything. And if I have to delete my old account, will everything (contacts, pictures, games, apps, etc.) be erased from my phone.

    My iPhone has my old email set up throught iCloud. How do I reset my new username with the device without deleting everything. And if I have to delete my old account, will everything (contacts, pictures, games, apps, etc.) be erased from my phone.

    Your old ID connects to an icloud account containing all your data (email, contacts, etc.)  If you then use a different ID, you will connect to a different account, which results in losing all your "apple" data, like emails, contacts, calendars, etc.
    However, Apple IDs are also used to connect to an itunes store account, with is different.  You can keep using the old itunes store ID to keep all your purchases (but if you change to a different ID, you will lose all purchased items) and use the new ID for icloud (but losing emails, contacts, etc. from the old account).

  • When I set up email for the first time, I had to enter a 4 digit pin. Since then, every time I switch my phone on, I have to enter this pin.   How do I remove or bypass the pin so that I can switch on the Iphone without having to first enter a pin?

    When I set up email for the first time, I had to enter a 4 digit pin. Since then, every time I switch my phone on, I have to enter this pin.   How do I remove or bypass the pin so that I can switch on the Iphone without having to first enter a pin?

    Go to Settings>General>Passcode Lock>tap Turn Passcode Lock Off, enter your "pin".
    Edit:  Are you saying you are getting a prompt for your email pin, or are you talking about the passcode lock that appears when you turn the phone on?

  • How do I email photos taken on the iphone, without having them embedded in the email?  I would like to have them as attachments, not shown in the body of the email)

    How do I email photos taken on the iphone, without having them embedded in the email? I would like to have them as attachments, not shown in the body of the email.

    @ Philly
    Yes there is,
    When you recieve a mail with an attachement (inline or as a picture) right click (or control click) the attachement and choose "show as symbol" or "show fullsize" (or completely or something like that, I don't work in English version). Mail will take this as a general preference.
    Ben

  • When ITunes changed their format it duplicated songs in my library.  How do I get rid of the duplicates without having to indivdually delete them.

    When ITunes changed their format it duplicated songs in my library.  How do I get rid of the duplicates without having to indivdually delete them?

    Go to view➡show duplicates then select all to delete

  • Changing from Active to Standby in a DHCP Failover scenario (on the fly) without deconfiguring operation...

    Hi all;
    Suppose I have set up a scope in SRV01 to be in Active mode. Is it possible to change its state to Standby mode (on the fly) without deconfigurig it and then configuring it again with my desired configuration?
    Thanks
    Please VOTE as HELPFUL if the post helps you and remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading
    the thread.

    Hi all;
    Suppose I have set up a scope in SRV01 to be in Active mode. Is it possible to change its state to Standby mode (on the fly) without deconfigurig it and then configuring it again with my desired configuration?
    Thanks
    Please VOTE as HELPFUL if the post helps you and remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading
    the thread.

  • PS CS6: how to create a left to right two-word-curved-headline gradient within the letters without having  to do each letter individually ?

    Q#1:
                I want to learn, how, with Photoshop and Illustrator to create a left to
    right two-word-curved-headline gradient within the letters without having
    to do each letter individually ???
    Q#2:

    https://www.google.com/search?sourceid=chrome-psyapi2&rlz=1C1CHFX_enUS546US546&ion=1&espv= &ie=UTF-8&q=Onlint%20Photoshop…

  • How can I view the content within the message without having to double click on the message. I used to be able to see content of the message alongside it .

    How can I view the content of the message without having to double click on it; I used to be able to see content of the message next to it .

    Is this in Mail?
    You can (I do all the time). The oreview window can be resized by dragging the message list window border - you might accidentally have closed it up

  • Any idea when we will see units new out of the box without a scratch on iPhone 5?

    Any idea when we will see units new out of the box without a scratch?  I was out at Apple to pick up my iPhone 5 in black on Oct 12th.   I opened the box in front of an Apple technician and there was a scratch on the edge.  So I told her I didn't want a scratched iPhone.  So she returned and brought out another phone.   Well, she couldn't get it to a accept the new iPhone because there's a 24hr waiting period when you make a return.  This is Verizon's policy, but of course we didn't find out until 2.5hrs later.
    So she says you'll have to return but we will hold this phone for you.  I was disappointed after being there for a total of 3.5hrs and no iPhone.   I returned on Saturday hoping the next iPhone didn't have a scratch.   I opened the box and there was a scratch!   I live 40 minutes from these store, so it's not close.
    I have an iPhone 4 that's in excellent condition!  I don't want a new iPhone 5 with a scratch, unless its a scratch caused by me.

    We're users here.  Why would you ask a question here that no one can answer?  Are you impaired in some way intellectually?

Maybe you are looking for

  • Help Missing movie.  DVD not burning as shown in Preview

    I created a DVD Project using 2 movies and one slideshow (separate buttons). Plays perfectly in the Preview within IDVD. I burned the disc, watched on the DVD Player, and the button that should have the first movie, plays the second movie. The other

  • How do I connect 7th generation Nano to miniboom speaker?

    How do I connect 7th generation ipod Nano to Mini Boom speaker bought at Apple store? 

  • Oracle adf form

    hi all, i have a scenario:in adf form i have a drop down with name of employees.when i select one employee then on submit i want an email to be sent to that employee.how i should accomplished this.pl provide some pointer. thanks

  • P55-GD65 takes long time in BIOS before booting

    Did a search on "long boot" but nothing relevant. Sorry if this has been already covered. First MSI board after two Giga-bytes: P55-GD65 Core i5-650 2x Corsair XMS3 DDR3 (DDR1333), total 4GB ATA133 HDD SATA DVD-RW MSI R4550 graphics card Windows XP S

  • Late Start in Regions

    Hi Can someone tell me what to do about late first notes in some regions? I've got a bass drum note on beat one of measure one that won't play unless I back it away from beat one 20 ticks or so. It plays okay on cycles or loops but not on the startin