Monday, April 11, 2011

Can I develop an iPhone app using java?

Hi

Is it possible to develop applications for the iPhone using Java? And if so, does it allow the use of custom jar files?

Thanks.

From stackoverflow
  • That would be a no. The Apple agreement says that no interpreted/other languages are allowed. period.

    Marcelo Cantos : Java isn't an interpreted language. Of course, since you answered this, Java has become explicitly disallowed. :-/
  • objective c

  • AlcheMo might be worth a look (I haven't had time to investigate it at all yet)

  • Have you tried this: http://tinyurl.com/c9zpw2 the first link allows you to develop Java apps for iPhone. I haven't tested xmlvm but it might be what you need.

401.1 Error when accessing virtual directory pointing to network share

IIS5 is running on SERVER1.

One of the virtual directories in IIS, myfiles, is pointing to "A shared location on another computer", //SERVER2/myfilesshare

When I try to access the page: http://SERVER1/myfiles

... I get the error:

You are not authorized to view this page

HTTP 401.1 - Unauthorized: Logon Failed

Internet Information Services

I have triple-checked the "Connect As..." settings in IIS. The credentials I'm using to access the share are correct-- they work when connect to the share in Windows Explorer, but not through the IIS virtual directory. I've tried granting full permission to Everyone on the folder in SERVER2, but no luck.

Any thoughts?

From stackoverflow
  • try enabling windows authentication on the virtual directory security tab (in IIS).

    frankadelic : That causes a username/password prompt to pop up when I access the site. However, even if I then enter the correct credentials it doesn't work. Note the two servers are not part of the same domain.
  • Permission issues can be tricky. Try running filemon on the 'other computer' It can be downloaded over here: http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx (it's not a big application just a tiny lightweight tool)

    After you've started filemon, stop the monitor process (I believe it's turned on by default when you start the application), clear the logged data, create a filter for the folder you have trouble getting access to. Start the monitor process. Request your webpage. Stop the monitor process and look for "access denied" messages in filemon. When found, filemon will also mention the name of the actual user which is trying to get access. This might help you to get to a solution.

    Btw when using Windows Server 2008 you will need processmon instead: http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx

    frankadelic : For some reason, filemon isn't showing anything relevant to that file on the shared machine. Event Viewer revealed that ASPNET did not have permissions on the web.config file on the network share. How can I give the local ASPNET user on server1 access to server2?
    Lex Li : Well, can you also create an ASPNET account on that server and assign relevant permissions? Also you may try to run ASP.NET application under a domain account.

Google Spreadsheet range names

In Google Docs Spreadsheets, one can use Range Names to put labels on ranges of cells to make formulas more legible. In most formulas, one can use the range C:C to denote the entire C column, and C2:C to denote the entire C column after and including C2.

Is there a way to create range names of the same nature? When I try C:C or C2:C or Sheet!C:C or 'Sheet'!C:C I always get the error "The range you specified is not in a valid range format." I would like the range name to expand as my form adds rows to my spreadsheet. Thanks.

From stackoverflow
  • I don't think so... even if you select a column manually while in the Range Name selector, it complains. That would be a nice feature and it would make sense since they support column ranges for formulas already.

How to use the JFace FileDialog from within an Eclipse plugin in a modeless way?

I am writing an Eclipse plugin, and in response to some action I am interesting in starting a series of operations (within a separate job). One of these operations is to request the user to provide a filename, which I'm trying to do with the JFace JDialog.

However, I'm not clear how to do this in a modeless way; for example, where do I obtain a display and shell? How do I ensure the UI continues to work while the developer can edit stuff in the dialog?

From stackoverflow
  • May be you could see how Eclipse itself does it:

    FindAndReplaceDialog.java

     /**
      * Creates a new dialog with the given shell as parent.
      * @param parentShell the parent shell
      */
     public FindReplaceDialog(Shell parentShell) {
         super(parentShell);
    
         fParentShell= null;
    
         [...]
    
         readConfiguration();
    
         setShellStyle(SWT.CLOSE | SWT.MODELESS | SWT.BORDER | SWT.TITLE | SWT.RESIZE);
         setBlockOnOpen(false);
     }
    
     /**
      * Returns this dialog's parent shell.
      * @return the dialog's parent shell
      */
     public Shell getParentShell() {
         return super.getParentShell();
     }
    
    /**
     * Sets the parent shell of this dialog to be the given shell.
     *
     * @param shell the new parent shell
     */
    public void setParentShell(Shell shell) {
        if (shell != fParentShell) {
    
            if (fParentShell != null)
                fParentShell.removeShellListener(fActivationListener);
    
            fParentShell= shell;
            fParentShell.addShellListener(fActivationListener);
        }
    
        fActiveShell= shell;
    }
    

    It does manage its parent shell depending on the focus of the Dialog.

     /**
      * Updates the find replace dialog on activation changes.
      */
     class ActivationListener extends ShellAdapter {
         /*
          * @see ShellListener#shellActivated(ShellEvent)
          */
         public void shellActivated(ShellEvent e) {
             fActiveShell= (Shell)e.widget;
             updateButtonState();
    
             if (fGiveFocusToFindField && getShell() == fActiveShell && 
                   okToUse(fFindField))
                 fFindField.setFocus();
    
         }
    
         /*
          * @see ShellListener#shellDeactivated(ShellEvent)
          */
         public void shellDeactivated(ShellEvent e) {
             fGiveFocusToFindField= false;
    
             storeSettings();
    
             [...]
    
             fActiveShell= null;
             updateButtonState();
         }
     }
    

    A ShellAdapter is provides default implementations for the methods described by the ShellListener interface, which provides methods that deal with changes in state of Shell.

  • The importent thing is that the style value should include SWT.MODELESS.

    The style is one of the most important things in SWT you should look at, because you can control and initialize a lot only because of the styel value.

vector scope with struct

Hi,

Beginner question here:

im reading a file, storing the feilds into struct members, then storing the name of the struct into a vector.

I output the size of my vector and debug it to see if it worked and i have the feilds from the file isolated.

im doing this in a vector *ptrFunc() function.

and i return the &vectorObject so i dont need to use a vector type ptr obj declaration.

Moving from one function to the other, even with my return type, do i need to parse the file all over again?

Heres some code, im dont think im being very clear:

  //Varaible Declartions/Intializations
  //Open File

   vector<myStruct> *firstFunc()
   {

    while ( !inFile->eof() )
    {
 // Isolating each feild delimited by commas
 getline( *inFile, str1, ',' );
 myStruct.f1 = str1;

 getline( *inFile, str2, ',' );
 myStruct.f2 = str2;

 getline( *inFile, str3, ',' );
 myStruct.f3 =  atof( str3.c_str()  );

 getline( *inFile, str4 );
 myStruct.f4 = atof( str4.c_str() );

 v.push_back( myStruct );
       // We have the isolated feilds in the vector...
       // so we dance
        }
     return &v;
      }
   // Now do i still have to do the getlines and push_back with the vector again in  another function?

   vector<myStruct> *otherFunc()
   {
      sStruct myStruct;
      vector<myStruct> *v = firstFunc(),
      vInit;
      v = &vInit
      vInit.push_back( myStruct );
      ...

so thats where i debug it and my Structure Members have lost all data!

What should i prolly do in the first function so that my struct members do not lose their data?

My guess is to just create a void function or something. But then storing that into a vector would then be the problem.

Im just have scoping issues. :p

From stackoverflow
  • Is it perhaps so that the vector 'v' you return from firstFunc() is allocated on the stack? If so, then that's probably your problem, since you're returning the address of an object that is going out of scope as the function exits.

    So fix that, return the vector by value, or create it on the heap using new.

  • Declare your functions this way:

    void firstFunc(vector<myStruct> &v) 
    {
    ...
    }
    
    void otherFunc(vector<myStruct> &v) 
    {
    ...
    }
    

    and use them this way

    void foo()
    {
    vector<myStruct> v;
    firstFunc(v);
    otherFunc(v);
    }
    

Stack unwinding in case of structured exceptions

This question provides more clarity on the problem described here. I did some more investigation and found that the stack unwinding is not happening in the following piece of code:

class One
{
public:
    int x ;
};

class Wrapper
{
public:
    Wrapper(CString csText):mcsText(csText)
    {
     CString csTempText;
     csTempText.Format("Wrapper constructor :: %s\n", mcsText);
     OutputDebugString(csTempText);
    }

    ~Wrapper()
    {
     CString csTempText;
     csTempText.Format("Wrapper destructor :: %s\n", mcsText);
     OutputDebugString(csTempText);
    }
    CString mcsText;
};
class Test
{
    public:

    void notifyError()
    {
        try
     {
      int x = 10; 
     }
     catch(...)  {}
    }

    void OnRecvBuffer()
    {
     try
     {
      Wrapper a("AddRef"); 
      One* p = NULL;
      p->x = 10;
     }
     catch(...)
     {
      notifyError();
     } 
    } 
};



int main() 
{
    Test* pTest = new Test;

    pTest->OnRecvBuffer();

    OutputDebugString("Test");
}

I compiled this code using VC6 SP5 compiler and the output is "Wrapper constructor :: AddRef!!!" (i.e. the destructor of wrapper object which was constructed on stack is not called. Is this the expected behavior ? or is it a bug with VC compiler ? Can I use some compiler flags so that the stack unwinding happens in this case?

From stackoverflow
  • The C++ standard does not give anything to work with in case of Undefined Behavior. Even if MS does. That's a platform specific thing -- so beware. Some such floating point exceptions are turned to Win32 exceptions which you can attempt to catch with _set_se_translator(). The problem is you can catch Win32 exceptions but then your stack will not be unwound properly. At least that is not something you can bet your life on. Wherein lies the futility of the exercise.

    Update: The exception is thrown intentionally to check the stack unwinding. The question is why Wrapper class's destructor is not getting called. – Naveen

    If this is the case -- don't do it. There are better ways to throw exceptions than via Undefined Behavior.

    E.g:

    void OnRecvBuffer()
    {
        try
        {
            Wrapper a("AddRef");    
            throw 42; // this'll throw an exception without invoking UB
        }
        catch(...)
        {
            notifyError();
        }
    }
    

    You cannot dereference a NULL pointer. You are invoking Undefined Behavior here:

    One* p = NULL;
    p->x = 10;
    

    After that line all bets are off and you could have killed us all ;)

    p is a pointer to a One object. It should contain the address of an One object. You have initialized it to 0 -- there is no object at address 0. 0 is not a valid address for any object (this is guranteed by the standard).

    Naveen : The exception is thrown intentionally to check the stack unwinding. The question is why Wrapper class's destructor is not getting called.
    dirkgently : As I have pointed out that is UB -- what happens when you invoke UB is not defined. No point discussing that. There are other better ways to throw exceptions.
    bk1e : The example program invoked what is undefined behavior for standard C++, but the question is about Microsoft SEH (Structured Exception Handling), not standard C++ exceptions.
    dirkgently : I can figure that out. But a) SEH is never mentioned in OP's question. b) doing things wrong don't make it a right.
    dirkgently : So, stop downvoting my answer since this is perfectly correct.
  • Because C++ regular exception does not handle this kind of exception, you have to use SEH which does not know anything about the app and does not unwind.

  • If you want to use SEH, you must use _set_se_translator function and /EHa compiler option.

  • This is undefined behavior:

    One* p = NULL;
    p->x = 10;
    

    At this point the application is free to crash without unwinding the stack.
    If you want to test the stack unwinding replace this with:

     throw 42; // Life the Universe and Everything thrown away
    

    You should not dynamically allocate all your objcts this is C++ not Java!

    int main() 
    {
        Test    pTest;   // Note the lack of new!
    
        pTest.OnRecvBuffer();
    
        OutputDebugString("Test");
    }
    
  • This is indeed a problem with VC6.

    Please refer to the following article for a good explanation: http://www.thunderguy.com/semicolon/2002/08/15/visual-c-exception-handling/

Best Mind Map Software

I like to use mind mapping software when I first start a project to gather specifications. What are the best free and commercial mind mapping applications?

From stackoverflow
  • MindJet MindManager. I use it on my Tablet PC and love it.

  • I've used FreeMind before: http://freemind.sourceforge.net/wiki/index.php/Main_Page

    It's written in Java and a little clunky, but it gets the job done (for free!).

  • Mindomo is a nice web-based mind-mapping tool. There's both a free and a paid version available; I've used the free one on occasion, and it's really well done.

  • CMAP Tools is a very good one that I have used before. It generates websites of your maps and allow you to attach documents etc.

  • Personal Brain 4 is the best mind mapping software that I've come across. It's available on all major platforms and has free and commercial editions. It makes use of a dynamic GUI that is able to map both hierarchical as well as network relationships.

  • imindmap

  • You might also want to take a look at Tree, which is for the Mac.

  • [I am plugging my own product here, but it's 1) free 2) it's so free that currently I make no money from it in any form.]

    I recommend my .Net product, TheKBase, or the Flex/ASP.NET version (although I wouldn't mention that fact if we weren't on StackOverflow), which is hosted by me here. Why is it good for mind-mapping?

    • Because it works in a way that we are used to: Windows-Explorer type tree (or whatever you want to call it, you get the point).
    • But in TheKBase, instead, they are multiple-hierarchical (multiple children AND parents).
    • That's it. There are snippets which have a title, text (including links, but no attachments (yet? ever?)), and an icon. And they can be arranged in a multiple-hierarchical fashion. Totally simple, like your brain (we're trying to mind-map, right?), but able to handle structures of any complexity. Like your brain.

    Now you might want to see a giant cool clicky map like PersonalBrain, which is interesting and beautiful but in the end it's really cumbersome (even though their product is way more advanced in terms of overall features, like attachments, and obviously has more person-hours dedicated to it). How can I demonstrate that other maps are cumbersome? Because PersonalBrain, aside from the really cool map, uses 'tags.' In TheKBase, there are no tags. One concept covers everything: a multiple hierarchy running in one direction (because hierarchies need to have a flow direction: free will is too hard to handle).

    And it works and you can find stuff and once you do, you can work on it without worrying about 'where it really is' in the hierarchy. Because it's actually in multiple places, one of which is as a child of the Search Results snippet. Some of those other places might interest you... hence it's got a Parents' Pane as well (just the hierarchy flipped).

    And it works, and it's stable, and we, I mean I, fix a all known bugs so it's way more stable and dependable than many other freewares [sic] of its class... I keep my important stuff in it, in fact.

    Yar : For some reason this answer has been getting some attention of late, so I might add that I have an Alpha-running-on-Mono for OSX version now, that I hope to release sometime soon.
  • Forever conceptdraw mind map.

  • mindmeister is my favourite so far. Nice web interface. Its free to use online, and they offer an offline (that uses google gears) version that you pay a subscription for.

  • I find XMind (free) to be pretty good.

  • I use Mindmanager and it does the biz. It's commercial (a couple of hundred I seem to recall) and they seem to be very active in adding features. There is a web version as well as desktop and one thing I thought was cool (but haven't ever really used ;-) is that it can output your interactive mind maps into a pdf ...