Search Results

Search found 45845 results on 1834 pages for 'static void main'.

Page 2/1834 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • What do I return if the return type of a method is Void? (Not void!)

    - by DR
    Due to the use of Generics in Java I ended up in having to implement a function having Void as return type: public Void doSomething() { //... } and the compiler demands that I return something. For now I'm just returning null, but I'm wondering if that is good coding practice... I've also tried Void.class, void, Void.TYPE, new Void(), no return at all, but all that doesn't work at all. (For more or less obvious reasons) (See this answer for details) So what am I supposed to return if the return type of a function is Void? What's the general use of the Void class? EDIT: Just to spare you the downvotes: I'm asking about V?oid, not v?oid. The class Void, not the reserved keyword void.

    Read the article

  • SSH main process ended

    - by Khaled
    I have a running ubuntu server 10.04.1. When I tried to login to the server via ssh, I could not. Instead, I got connection refused error. I tried to ping the machine and I got reply! So, the clear reason is that SSH daemon is stopped. After reboot, I was able to login to my server via ssh. After some time, I looked at my logs /var/log/syslog and found the following records: Jan 16 10:57:09 myserver init: ssh main process ended, respawning Jan 16 10:57:09 myserver init: ssh main process (2465) terminated with status 255 Jan 16 10:57:09 myserver init: ssh main process ended, respawning Jan 16 10:57:09 myserver init: ssh main process (2469) terminated with status 255 Jan 16 10:57:09 myserver init: ssh main process ended, respawning Jan 16 10:57:09 myserver init: ssh main process (2473) terminated with status 255 Jan 16 10:57:09 myserver init: ssh main process ended, respawning Jan 16 10:57:09 myserver init: ssh main process (2477) terminated with status 255 Jan 16 10:57:09 myserver init: ssh main process ended, respawning Jan 16 10:57:09 myserver init: ssh main process (2481) terminated with status 255 Jan 16 10:57:09 myserver init: ssh main process ended, respawning Jan 16 10:57:09 myserver init: ssh main process (2485) terminated with status 255 Jan 16 10:57:09 myserver init: ssh main process ended, respawning Jan 16 10:57:09 myserver init: ssh main process (2489) terminated with status 255 Jan 16 10:57:09 myserver init: ssh main process ended, respawning Jan 16 10:57:09 myserver init: ssh main process (2493) terminated with status 255 Jan 16 10:57:09 myserver init: ssh main process ended, respawning Jan 16 10:57:09 myserver init: ssh main process (2497) terminated with status 255 Jan 16 10:57:09 myserver init: ssh main process ended, respawning Jan 16 10:57:09 myserver init: ssh main process (2501) terminated with status 255 Jan 16 10:57:09 myserver init: ssh respawning too fast, stopped I searched for a similar problem/solution. Some people said that this is caused by the SSH daemon trying to start before networking and they suggest to change ListenAddress in /etc/ssh/sshd_config to be 0.0.0.0. I think this is not the cause in my case, because my problem occurs after system is up and running. Any idea what is causing this? This is ubuntu server and it should be running and accessed remotely using ssh.

    Read the article

  • Don't Use "Static" in C#?

    - by Joshiatto
    I submitted an application I wrote to some other architects for code review. One of them almost immediately wrote me back and said "Don't use "static". You can't write automated tests with static classes and methods. "Static" is to be avoided." I checked and fully 1/4 of my classes are marked "static". I use static when I am not going to create an instance of a class because the class is a single global class used throughout the code. He went on to mention something involving mocking, IOC/DI techniques that can't be used with static code. He says it is unfortunate when 3rd party libraries are static because of their un-testability. Is this other architect correct? update: here is an example: APIManager - this class keeps dictionaries of 3rd party APIs I am calling along with the next allowed time. It enforces API usage limits that a lot of 3rd parties have in their terms of service. I use it anywhere I am calling a 3rd party service by calling Thread.Sleep(APIManager.GetWait("ProviderXYZ")); before making the call. Everything in here is thread safe and it works great with the TPL in C#.

    Read the article

  • How to deal with static utility classes when designing for testability

    - by Benedikt
    We are trying to design our system to be testable and in most parts developed using TDD. Currently we are trying to solve the following problem: In various places it is necessary for us to use static helper methods like ImageIO and URLEncoder (both standard Java API) and various other libraries that consist mostly of static methods (like the Apache Commons libraries). But it is extremely difficult to test those methods that use such static helper classes. I have several ideas for solving this problem: Use a mock framework that can mock static classes (like PowerMock). This may be the simplest solution but somehow feels like giving up. Create instantiable wrapper classes around all those static utilities so they can be injected into the classes that use them. This sounds like a relatively clean solution but I fear we'll end up creating an awful lot of those wrapper classes. Extract every call to these static helper classes into a function that can be overridden and test a subclass of the class I actually want to test. But I keep thinking that this just has to be a problem that many people have to face when doing TDD - so there must already be solutions for this problem. What is the best strategy to keep classes that use these static helpers testable?

    Read the article

  • Static initializer in Java

    - by Szere Dyeri
    My question is about one particular usage of static keyword. It is possible to use static keyword to cover a code block within a class which does not belong to any function. For example following code compiles: public class Test { private static final int a; static { a = 5; doSomething(a); } private static int doSomething(int x) { return (x+5); } } If you remove the static keyword it complains because the variable a is final. However it is possible to remove both final and static keywords and make it compile. It is confusing for me in both ways. How am I supposed to have a code section that does not belong to any method? How is it possible to invoke it? In general, what is the purpose of this usage? Or better, where can I find documentation about this?

    Read the article

  • serving static assets via http is really slow compared to sshfs (apache2/nginx)

    - by s1lv3r
    After migrating to a new VPS I had some users complaining about slow loading images on their sites. After creating some test files with dd I realized that I can download all files via sshfs with full speed while downloads via web are painfully slow. The larger the file is and the longer the transfer takes, the slower the transfer speed gets. I thought I had some problems with Apache and just spend the whole evening with replacing Apache2 against nginx for static file serving - with no effect at all. No I/O wait states in top. Tons of RAM free, no high CPU utilization and hdparm shows a decent I/O performance at all times. I just have no idea anymore, what's happening on this server. This is a link to a demo file: http://master.dealux.de/file.tgz Anybody an idea what I can check out?

    Read the article

  • Google Analytics on Static Site Hosted by GAE

    - by Cody Hess
    I finagled hosting a static site on Google App Engine at http://corbyhaas.com The HTML when visiting the URL shows some meta information and a frame to the site's actual address: http://cody-static-sites.appspot.com/corbyhaas which has the content. This is done automagically by Google App Engine. I've set up Google Analytics by including their script in my index.html, but the report shows 100% of visits coming from referring site "corbyhaas.com", which is useless information. Has anyone set up Google Analytics for a static GAE site? Is there a setting in my Analytics dashboard I can tweak, or is this a hazard of using Google App Engine for static content? Also, while it's not relevant here (but could be for future sites), does GAE's method of showing only meta information with frames for static data affect SEO?

    Read the article

  • Do private static methods in C# hurt anything?

    - by fish
    I created a private validation method for a certain validation that happens multiple times in my class (I can't store the validated data for various reasons). Now, ReSharper suggests that the function could be made static. I'm a little reluctant to do so due known problems with static methods. It would be a private static method. My question is, can private static methods cause similar coupling and testing problems like public static methods? Is it a bad practice? I would guess not, but I'm not sure if there is a pitfall here.

    Read the article

  • To static or not to static

    - by Idsa
    I really like to use static methods (especially for helpers classes). But as static methods are not stubbable, eventually they are a bad practice, aren't they? So I have to choose between static methods usage convenience and testability. Is there any compromise?

    Read the article

  • Static property references non-static method

    - by rhj4
    How can a static property reference a nonstatic method? Example: public static int UserID { get { return GetUserID(); } } private int GetUserID() { return 1; } When I try to compile this, I get the error: "An object reference is required for he non-static field, method or property "GetUserID()"

    Read the article

  • [C++]Advantage of using a static member function instead of an equivalent non-static member function

    - by jonathanasdf
    I was wondering whether there's any advantages to using a static member function when there is a non-static equivalent. Will it result in faster execution (because of not having to care about all of the member variables), or maybe less use of memory (because of not being included in all instances)? Basically, the function I'm looking at is an utility function to rotate an integer array representing pixel colours an arbitrary number of degrees around an arbitrary centre point. It is placed in my abstract Bullet base class, since only the bullets will be using it and I didn't want the overhead of calling it in some utility class. It's a bit too long and used in every single derived bullet class, making it probably not a good idea to inline. How would you suggest I define this function? As a static member function of Bullet, of a non-static member function of Bullet, or maybe not as a member of Bullet but defined outside of the class in Bullet.h? What are the advantages and disadvantages of each?

    Read the article

  • Syntactic sugar in PHP with static functions

    - by Anna
    The dilemma I'm facing is: should I use static classes for the components of an application just to get nicer looking API? Example - the "normal" way: // example component class Cache{ abstract function get($k); abstract function set($k, $v); } class APCCache extends Cache{ ... } class application{ function __construct() $this->cache = new APCCache(); } function whatever(){ $this->cache->add('blabla'); print $this->cache->get('blablabla'); } } Notice how ugly is this->cache->.... But it gets waay uglier when you try to make the application extensible trough plugins, because then you have to pass the application instance to its plugins, and you get $this->application->cache->... With static functions: interface CacheAdapter{ abstract function get($k); abstract function set($k, $v); } class Cache{ public static $ad; public function setAdapter(CacheAdapter $a){ static::$ad = $ad; } public static function get($k){ return static::$ad->get($k); } ... } class APCCache implements CacheAdapter{ ... } class application{ function __construct(){ cache::setAdapter(new APCCache); } function whatever() cache::add('blabla', 5); print cache::get('blabla'); } } Here it looks nicer because you just call cache::get() everywhere. The disadvantage is that I loose the possibility to extend this class easily. But I've added a setAdapter method to make the class extensible to some point. I'm relying on the fact that I won't need to rewrite to replace the cache wrapper, ever, and that I won't need to run multiple application instances simultaneously (it's basically a site - and nobody works with two sites at the same time) So, am doing it wrong?

    Read the article

  • non-static variable cannot be referenced from a static context (java)

    - by Greg
    I ask that you ignore all logic.. i was taught poorly at first and so i still dont understand everything about static crap and its killing me. My error is with every single variable that i declare then try to use later inside my methods... i get the non-static variable cannot~~ error I can simply put all the rough coding of my methods inside my cases, and it works but then i cannot use recursion... What i really need is someone to help on the syntax and point me on the right direction of how to have my methods recognize my variables at the top... like compareCount etc thanks public class MyProgram7 { public static void main (String[]args) throws IOException{ Scanner scan = new Scanner(System.in); int compareCount = 0; int low = 0; int high = 0; int mid = 0; int key = 0; Scanner temp; int[]list; String menu, outputString; int option = 1; boolean found = false; // Prompt the user to select an option menu = "\n\t1 Reads file" + "\n\t2 Finds a specific number in the list" + "\n\t3 Prints how many comparisons were needed" + "\n\t0 Quit\n\n\n"; System.out.println(menu); System.out.print("\tEnter your selection: "); option = scan.nextInt(); // Keep reading data until the user enters 0 while (option != 0) { switch (option) { case 1: readFile(); break; case 2: findKey(list,low,high,key); break; case 3: printCount(); break; default: outputString = "\nInvalid Selection\n"; System.out.println(outputString); break; }//end of switch System.out.println(menu); System.out.print("\tEnter your selection: "); option = scan.nextInt(); }//end of while }//end of main public static void readFile() { int i = 0; temp = new Scanner(new File("CS1302_Data7_2010.txt")); while(temp.hasNext()) { list[i]= temp.nextInt(); i++; }//end of while temp.close(); System.out.println("File Found..."); }//end of readFile() public static void findKey() { while(found!=true) { while(key < 100 || key > 999) { System.out.println("Please enter the number you would like to search for? ie 350: "); key = scan.nextInt(); }//end of inside while //base if (low <= high) { mid = ((low+high)/2); if (key == list[mid]) { found = true; compareCount++; }//end of inside if }//end of outside if else if (key < list[mid]) { compareCount++; high = mid-1; findKey(list,low,high,key); }//end of else if else { compareCount++; low = mid+1; findKey(list,low,high,key); }//end of else }//end of outside while }//end of findKey() public static void printCount() { System.out.println("Total number of comparisons is: " + compareCount); }//end of printCount }//end of class

    Read the article

  • Regarding C Static/Non Static Float Arrays (Xcode, Objective C)

    - by user1875290
    Basically I have a class method that returns a float array. If I return a static array I have the problem of it being too large or possibly even too small depending on the input parameter as the size of the array needed depends on the input size. If I return just a float array[arraysize] I have the size problem solved but I have other problems. Say for example I address each element of the non-static float array individually e.g. NSLog(@"array[0] %f array[1] %f array[2] %f",array[0],array[1],array[2]); It prints the correct values for the array. However if I instead use a loop e.g. for (int i = 0; i < 3; i++) { NSLog(@"array[%i] %f",i,array[i]); } I get some very strange numbers (apart from the last index, oddly). Why do these two things produce different results? I'm aware that its bad practice to simply return a non static float, but even so, these two means of addressing the array look the same to me. Relevant code from class method (for non-static version)... float array[arraysize]; //many lines of code later if (weShouldStoreValue == true) { array[index] = theFloat; index = index + 1; } //more lines of code later return array; Note that it returns a (float*).

    Read the article

  • Cannot make a static reference to the non-static type MyRunnable

    - by kaiwii ho
    Here is the whole code : import java.util.ArrayList; public class Test{ ThreadLocal<ArrayList<E>>arraylist=new ThreadLocal<ArrayList<E>>(){ @Override protected ArrayList<E> initialValue() { // TODO Auto-generated method stub //return super.initialValue(); ArrayList<E>arraylist=new ArrayList<E>(); for(int i=0;i<=20;i++) arraylist.add((E) new Integer(i)); return arraylist; } }; class MyRunnable implements Runnable{ private Test mytest; public MyRunnable(Test test){ mytest=test; // TODO Auto-generated constructor stub } @Override public void run() { System.out.println("before"+mytest.arraylist.toString()); ArrayList<E>myarraylist=(ArrayList<E>) mytest.arraylist.get(); myarraylist.add((E) new Double(Math.random())); mytest.arraylist.set(myarraylist); System.out.println("after"+mytest.arraylist.toString()); } // TODO Auto-generated method stub } public static void main(String[] args){ Test test=new Test<Double>(); System.out.println(test.arraylist.toString()); new Thread(new MyRunnable(test)).start(); new Thread(new MyRunnable(test)).start(); System.out.println(arraylist.toString()); } } my questions are: 1\ why the new Thread(new MyRunnable(test)).start(); cause the error: Cannot make a static reference to the non-static type MyRunnable ? 2\ what is the static reference refer to right here? thx in advanced

    Read the article

  • Most scalable way of serving a small set of static HTTP content

    - by Ekevoo
    The story: Hi guys. I'm among the people responsible for serving the results of the most anticipated (by number of people participating) annual entrance exam in my state. As such, when our results are published, the interest is overwhelming. In the past we delegated the responsibility of serving the results to the media, but that spoils a little the officialness of these results. This year we went with a little (long overdue) experiment of using lighttpd instead of Apache as well as other physical network optimizations I wasn't directly involved with. The results were very satisfactory. The server didn't choke even once, nor we saw any of the usual Twitter complaints on unavailability and/or slowness that were previously common. However, because we still delegated the first publication of the results to the media I'm still not 100% sure we can handle the load of actually publishing the results first. The question: Now because these files are like 14MB in total and a true lightweight Linux distribution isn't that big either, I'm thinking: what if next year we run full RAMdrive? Is there any? Is that useful? Is that worth it for a team that uses Debian almost exclusively? Are there other optimizations that I should be focusing on instead?

    Read the article

  • Linux, static lib referring to other static lib within an executable

    - by andras
    Hello, I am creating an application, which consists of two static libs and an executable. Let's call the two static libs: libusefulclass.a libcore.a And the application: myapp libcore instantiates and uses the class defined in libusefulclass (let's call it UsefulClass) Now, if I link the application in the following way: g++ -m64 -Wl,-rpath,/usr/local/Trolltech/Qt-4.5.4/lib -o myapp src1.o src2.o srcN.o -lusefulclass -lcore The linker complains about the methods in libusefulclass not being found: undefined reference to `UsefulClass::foo()' etc. I found a workaround for this: If UsefulClass is also instantiated within the source files of the executable itself, the application is linked without any problems. My question is: is there a more clean way to make libcore refer to methods defined in libusefulclass, or static libs just cannot be linked against eachother? TIA P.S.: In case that matters: the application is being developed in C++ using Qt, but I feel this is not a Qt problem, but a library problem in general.

    Read the article

  • Building iPhone static library for armv6 and armv7 that includes another static library

    - by Martijn Thé
    Hi, I have an Xcode project that has a "master" static library target, that includes/links to a bunch of other static libraries from other Xcode projects. When building the master library target for "Optimized (armv6 armv7)", an error occurs in the last phase, during the CreateUniversalBinary step. For each .o file of the libraries that is included by the master library, the following error is reported (for example, the FBConnectGlobal.o file): warning for architecture: armv6 same member name (FBConnectGlobal.o) in output file used for input files: /Developer_Beta/Builds/MTToolbox/MTToolbox.build/Debug-iphoneos/MTToolbox.build/Objects-normal/armv6/libMTToolbox.a(FBConnectGlobal.o) and: /Developer_Beta/Builds/MTToolbox/MTToolbox.build/Debug-iphoneos/MTToolbox.build/Objects-normal/armv7/libMTToolbox.a(FBConnectGlobal.o) due to use of basename, truncation and blank padding In the end, Xcode tells that the build has succeeded. However, when using the final static library in an application project, it won't build because it finds duplicate symbols in one part of build (armv6) and misses symbols in the other part of the build (armv7). Any ideas how to fix this? M

    Read the article

  • -(void)... does not work/appeal (iOS)

    - by user1012535
    Hi I've got a problem with my -(void) in my Xcode project for iOS. First of all here is the code ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController { IBOutlet UIWebView *webview; IBOutlet UIActivityIndicatorView *active; UIAlertView *alert_start; UIAlertView *alert_error; } -(IBAction)tele_button:(id)sender; -(IBAction)mail_button:(id)sender; -(IBAction)web_button:(id)sender; -(IBAction)news_button:(id)sender; @end ViewController.m #import "ViewController.h" @implementation ViewController - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } #pragma mark - View lifecycle - (void)viewDidLoad { [super viewDidLoad]; //Stop Bounce for WebView for (id subview in webview.subviews) if ([[subview class] isSubclassOfClass: [UIScrollView class]]) ((UIScrollView *)subview).bounces = NO; //First Start Alert [alert_start show]; NSLog(@"first alert"); NSString *start_alert = [[NSUserDefaults standardUserDefaults] objectForKey:@"alert_start"]; if(start_alert == nil) { [[NSUserDefaults standardUserDefaults] setValue:@"1" forKey:@"alert_start"]; [[NSUserDefaults standardUserDefaults] synchronize]; UIAlertView *alert_start = [[UIAlertView alloc] initWithTitle:@"iOptibelt" message:@"On some points this application need a internet connection." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert_start show]; [alert_start release]; } // Do any additional setup after loading the view, typically from a nib. [webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"home-de" ofType:@"html"]isDirectory:NO]]]; NSLog(@"webview fertig"); } -(void)webViewDidStartLoad:(UIWebView *) webview { [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; [active startAnimating]; NSLog(@"lade"); } -(void)webViewDidFinishLoad:(UIWebView *) webview { [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; [active stopAnimating]; NSLog(@"fertig"); } -(void)webView: (UIWebView *) webview didFailLoadWithError:(NSError *)error{ NSLog(@"lade error"); UIAlertView *alert_error = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Can't connect. Please check your internet Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert_error show]; [alert_error release]; }; - (IBAction)tele_button:(id)sender{ NSLog(@"it's connected!"); //Local HTML Call Button NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"phone" ofType:@"html"]isDirectory:NO]]; [webview loadRequest:theRequest]; } - (IBAction)mail_button:(id)sender{ NSLog(@"it's connected!"); //Mail App Mail Button [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://[email protected]"]]; } - (IBAction)web_button:(id)sender{ NSLog(@"it's connected!"); //Local HTML Button NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString: @"http://optibelt.com"]]; [webview loadRequest:theRequest]; } - (IBAction)news_button:(id)sender{ NSLog(@"it's connected!"); //local Home Button NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"home-de" ofType:@"html"]isDirectory:NO]]; [webview loadRequest:theRequest]; } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } @end At last my 3. -(void) does not work and i ve no more idea what could be the problem.... -(void)webViewDidStartLoad:(UIWebView *) webview { [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; [active startAnimating]; NSLog(@"lade"); } -(void)webViewDidFinishLoad:(UIWebView *) webview { [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; [active stopAnimating]; NSLog(@"fertig"); } -(void)webView: (UIWebView *) webview didFailLoadWithError:(NSError *)error{ NSLog(@"lade error"); UIAlertView *alert_error = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Can't connect. Please check your internet Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert_error show]; [alert_error release];

    Read the article

  • Google Analytics setting cookies on static content despite being on entirely separate domain

    - by Donald Jenkins
    I recently decided to comply with the YSlow recommendation that static content is hosted on a cookieless domain. As I already use the root of my domain (donaldjenkins.com) to host my website—on which Google Analytics sets a few cookies—that meant I had to move the CNAME URL for the CDN serving the static files from cdn.donaldjenkins.com to an entirely separate, dedicated domain. I purchased cdn.dj (yes, it's a real Djibouti domain name), hosted the files on the root (which contains nothing else, other than a robots.txt file) and set a CNAME of e.cdn.dj for the CDN. This setup works, but I was rather surprised to find that YSlow was still flagging the static files for not being cookie-free: here's a screenshot: The cdn.djdomain was new, and was never used for anything other than hosting these static files. Running httpfox on the site shows the _utma and _utmz Google Analytics cookies are being set on the static files listed above—despite their being hosted on an entirely separate, dedicated domain. Here's my Google Analytics code: //Google Analytics tracking code var _gaq=[['_setAccount','UA-5245947-5'],['_trackPageview']]; (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0]; g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js'; s.parentNode.insertBefore(g,s)}(document,'script')); // [END] Google Analytics tracking code I'm not obsessing about this issue—I know it's not really affecting server performance—but I'd like to just understand what is causing it not to go away...

    Read the article

  • Script + template to generate static web site?

    - by user702
    After giving it more thought, I don't actually need a PHP-based CMS for a small, static web site. Does someone know of a good solution that can run on Windows that would take basic HTML pages and JPG pictures, combine those with a template, and generate a static site ready to be FTPed to an web server? Thank you. Edit: For those looking for the same information, here's some well-known tools to create a static site: http://get-simple.info/ http://gpeasy.com/How_Easy http://textpattern.com/features http://nanoc.stoneship.org/ http://www.movabletype.com/

    Read the article

  • get static initialization block to run in a java without loading the class

    - by TP
    I have a few classes as shown here public class TrueFalseQuestion implements Question{ static{ QuestionFactory.registerType("TrueFalse", "Question"); } public TrueFalseQuestion(){} } ... public class QuestionFactory { static final HashMap<String, String > map = new HashMap<String,String>(); public static void registerType(String questionName, String ques ) { map.put(questionName, ques); } } public class FactoryTester { public static void main(String[] args) { System.out.println(QuestionFactory.map.size()); // This prints 0. I want it to print 1 } } How can I change TrueFalseQuestion Type so that the static method is always run so that I get 1 instead of 0 when I run my main method? I do not want any change in the main method. I am actually trying to implement the factory patterns where the subclasses register with the factory but i have simplified the code for this question.

    Read the article

  • Call static properties within another class in php

    - by ali A
    I have problem about calling a static property of a class inside another class. Class A { public $property; public function __construct( $prop ) { $this->property = $prop; } public function returnValue(){ return static::$this->property; } } Class B extends A { public static $property_one = 'This is first property'; public static $property_two = 'This is second property'; } $B = new B( 'property_one' ); $B->returnValue(); I expect to return This is first property But the Output is just the name a parameter input in __construct; When I print_r( static::$this->property ); the output is just property_one

    Read the article

  • Java - Class type from inside static initialization block

    - by DutrowLLC
    Is it possible to get the class type from inside the static initialization block? This is a simplified version of what I currently have:: class Person extends SuperClass { String firstName; static{ // This function is on the "SuperClass": // I'd for this function to be able to get "Person.class" without me // having to explicitly type it in but "this.class" does not work in // a static context. doSomeReflectionStuff(Person.class); // IN "SuperClass" } } This is closer to what I am doing, which is to initialize a data structure that holds information about the object and its annotations, etc... Perhaps I am using the wrong pattern? public abstract SuperClass{ static void doSomeReflectionStuff( Class<?> classType, List<FieldData> fieldDataList ){ Field[] fields = classType.getDeclaredFields(); for( Field field : fields ){ // Initialize fieldDataList } } } public abstract class Person { @SomeAnnotation String firstName; // Holds information on each of the fields, I used a Map<String, FieldData> // in my actual implementation to map strings to the field information, but that // seemed a little wordy for this example static List<FieldData> fieldDataList = new List<FieldData>(); static{ // Again, it seems dangerous to have to type in the "Person.class" // (or Address.class, PhoneNumber.class, etc...) every time. // Ideally, I'd liken to eliminate all this code from the Sub class // since now I have to copy and paste it into each Sub class. doSomeReflectionStuff(Person.class, fieldDataList); } }

    Read the article

  • Void in main and keeping Dos program from dying

    - by TimothyTech
    Alright, so im using bloodshed complier, first thing i should note is im using a 2001 edition C++ for the aboslute beginner, was there any changes to C++ since 2001 that would effect the validity of this book? i ask because i know php has php5 and now php6 but i havent seen any C++3. now for the reason i asked that, in this code it uses, void main (void) why would i want an arguement to be void? what does this do. But when i run the " void main (void) in my compiler it says that main must have a "int" before it. so i cant have "void" main (void); also, once the code runs through, as long as there isnt a "cin" the program closes. is this normal behavior, is there a better way to stop this besides making a cin at the end of my program.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >