|
Part of the trouble I'm having here is that I'm ultimately trying to reproduce the Terminal line:
java -jar PolyGlot.jar <FILENAME_ARGUMENT >
Do you have any ideas for that? Any help would be appreciated.
|
|
|
|
|
task.launchPath = [currentpath stringByAppendingString:@"/java"];
Are you sure that the java executable is in that path? Printing out the full path at that point will tell you.
|
|
|
|
|
Ah, I do see what I was doing there! I was fundamentally misunderstanding how java was being referenced. I almost have it working at this point! Here's the code as it stands now:
int main(int argc, const char * argv[]) {
NSFileManager *filemgr;
NSString *currentpath;
filemgr = [[NSFileManager alloc] init];
currentpath = [filemgr currentDirectoryPath];
NSPipe *pipe = [NSPipe pipe];
NSFileHandle *file = pipe.fileHandleForReading;
NSTask *task = [[NSTask alloc] init];
task.launchPath = @"/usr/bin/java";
task.arguments = @[@"-jar", [currentpath stringByAppendingString:@"/PolyGlot.jar"], [NSString stringWithFormat:@"%c", argv]];
task.standardOutput = pipe;
[task launch];
NSData *data = [file readDataToEndOfFile];
[file closeFile];
NSString *grepOutput = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
NSLog (@"grep returned:\n%@", grepOutput);
return 0;
}
The only remaining problem is that the "-jar" argument seems to be ignored at this point. If I apply it by itself, Java recognizes it as an argument, but otherwise, it is only accepting "PolyGlot.jar". Is there something that I'm not doing correctly there?
Thanks for the help so far!
|
|
|
|
|
I don't know Objective-C, but I suspect that the first argument should be the same as task.launchPath , i.e the program name. That would then comply with the format of the argv array, as set by the shell when invoking programs from the command line.
|
|
|
|
|
The task.launchPath is the full path of the program to be run. Out of curiosity, I tried dropping " -jar" onto the end, but that made it fail when it looked for the executable "java -jar" rather than the executable "java" with the argument "-jar".
What's strange is that the "-jar" argument works correctly so long as it's the only one... Ultimately, the error I'm getting from Java at this point is "
Could not find or load main class ". This typically appears if you try to run a .jar file without the -jar argument.
Also, just for the sake of sanity, I'll specify that I can run "java -jar PolyGlot <FILENAME>" from the console, and it runs fine.
|
|
|
|
|
DraqueD wrote: I can run "java -jar PolyGlot <FILENAME>" from the console, and it runs fine. And I think those are the fields that you need in your arguments array. The last parameter you specify should be argv[1] as a string (%s), not a character (%c), as that is the filename passed in to your program. Something like:
task.launchPath = @"/usr/bin/java";
task.arguments = @[task.launchPath, @"-jar", [currentpath stringByAppendingString:@"/PolyGlot.jar"], [NSString stringWithFormat:@"%s", argv[1]]];
|
|
|
|
|
As a heads up, I found my solution! It turns out that the debug folder that this was running in gave Java particular troubles, and the behavior cleared up when I took my compiled app into a typical folder. Thanks to everyone who replied for the help!
|
|
|
|
|
I think there is an problem in executable path..Check out that
|
|
|
|
|
We've just completed an iOS app called Waffle which is launching in the new year and are looking for Node.js developers to join our team.
Waffle is a a community for you to share your thoughts & learn from the world around you. Jump into group chats with people who share your interests and enjoy fast, flowing conversations on the things you’re passionate about.
We have a 3 strong team with backgrounds working for Microsoft. EASA and are looking for hard working and passionate developers either part or full time.
If you're interested please email sharan@waffleapp.co
Sharan
|
|
|
|
|
In objective-c I’m try to create a statement that toggles a variable that switches between two numbers with a UIswitch controller
(a * b/w * r) c * h;
r needs to trigger two different numbers
when on needs to = .73
when off needs to = .66
int a=1;
int b=5.14;
int c = -.015;
int w =1;
int r =.73;// on=.73 and off= .66
int h=1;
int result;
result = (a * b/w * r) c * h;
NSLog (@"a*b/w*r)c*h;");
Is this possible
|
|
|
|
|
Member 11251240 wrote: Is this possible Most likely but your question is far from clear. In general terms you would write something like:
if (switch == ON)
r = .73;
else
r = .66;
But maybe I just don't understand what you are asking.
|
|
|
|
|
What is the core difference between C programming language and Objective-C programming language? Please help me to know with suitable examples. A lot of Thanks in Advance.
Regards
Online Visit
online visit
|
|
|
|
|
C and Objective-C have many differences.
First of all, C is procedure-oriented language while object-C is object-oriented language.
They have different syntaxes.
Objective-C is more familiar to smalltalk than C/C++.
e.g. of calling method
c: foo(param1, para2, ...);
objective-c: [object foo:param];
There are many differences between two languages.
jian
|
|
|
|
|
thanks sir, but i need some real life example to clear this concept more.
Regards
Online Visit
|
|
|
|
|
Google will find you lots of documentation on both languages.
|
|
|
|
|
|
I don't think so. It's quite reasonable to want to learn the differences, just a pity he/she (like so many others) can't make the effort to do a bit of research.
|
|
|
|
|
Nothing wrong with his question.
But I checked his user id, signature in his message & links in his profile so thought ....
|
|
|
|
|
after looking at his signature I am thinking the same thing about this being spam now.
|
|
|
|
|
I disagree, the question has nothing in it that could be construed as spam. And there are quite a few members who have links to their own business in their signatures.
|
|
|
|
|
|
|
hey all. i have an UIWebView(tarayici in my situation) in view controller. it works fine when its scroll view delegate is not assigned to view controller. but i need to know when it is scrolled that is why i wrote this code.
self.tarayici.scrollView.delegate = self;
but when i write this down then webview acts so weird. for example after this code when i want to scroll then it scrolls only once if i make 3 or 4 attempts. so how can make it work more efficient with that code ?
vemedya.com
|
|
|
|
|
Before you added your UIWebView did you set the user interaction??
webView.userInteraction = YES;
|
|
|
|
|
 i think i found the solution. The commented UIview animation block locked the main thread i think that is why Scroll View couldnt response to the new touches. but with this new animation block it works well.
- (void) scrollViewDidScroll:(UIScrollView *)scrollView
{
if (self.lastContentOffset > scrollView.contentOffset.y)
{
if (self.altView.frame.size.height + self.altView.frame.origin.y > self.screenHeight)
{
[UIView animateWithDuration:0.5f delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
self.altView.frame = CGRectMake(0, self.altView.frame.origin.y-1, 320, 48);
self.tarayici.frame = CGRectMake(0, self.tarayici.frame.origin.y, 320, self.tarayici.frame.size.height-1);
} completion:^(BOOL finished) {
}];
}
}
else if (self.lastContentOffset < scrollView.contentOffset.y)
{
if (self.altView.frame.origin.y < self.screenHeight)
{
[UIView animateWithDuration:0.5f delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
self.altView.frame = CGRectMake(0, self.altView.frame.origin.y + 1, 320, 48);
self.tarayici.frame = CGRectMake(0, self.tarayici.frame.origin.y, 320, self.tarayici.frame.size.height+1);
} completion:^(BOOL finished) {
}];
}
}
self.lastContentOffset = scrollView.contentOffset.y;
}
vemedya.com
modified 22-May-14 4:15am.
|
|
|
|