Get a resource using getResource()
TestGameTable.class.getResource(“/unibo/lsb/res/dice.jpg”); leading slash to denote the root of the classpath slashes instead of dots in the path you can call getResource() directly on the class.
TestGameTable.class.getResource(“/unibo/lsb/res/dice.jpg”); leading slash to denote the root of the classpath slashes instead of dots in the path you can call getResource() directly on the class.
IF we’re talking .NET, try Scripting .NET applications with VBScript over on CodeProject. Lots of concrete examples there. Below are sites implementing various application extension techniques ClearScript – Makes V8, VBScript and JScript available to .NET apps CS-Script – The C# Script Engine Plugin Architecture using C# Opinio plugin architecture Notes on the Eclipse Plug-in … Read more
If your actual concern is the dynamicness of the webapp context (the “AppName” part), then just retrieve it dynamically by HttpServletRequest#getContextPath(). <head> <link rel=”stylesheet” href=”https://stackoverflow.com/questions/4764405/${pageContext.request.contextPath}/templates/style/main.css” /> <script src=”${pageContext.request.contextPath}/templates/js/main.js”></script> <script>var base = “${pageContext.request.contextPath}”;</script> </head> <body> <a href=”${pageContext.request.contextPath}/pages/foo.jsp”>link</a> </body> If you want to set a base path for all relative links so that you don’t need to … Read more
You cannot do this File src = new File(resourceUrl.toURI()); //ERROR HERE it is not a file! When you run from the ide you don’t have any error, because you don’t run a jar file. In the IDE classes and resources are extracted on the file system. But you can open an InputStream in this way: … Read more
There are a couple possibilities: use ld’s capability to turn any file into an object (Embedding binary blobs using gcc mingw): ld -r -b binary -o binary.o foo.bar # then link in binary.o use a bin2c/bin2h utility to turn any file into an array of bytes (Embed image in code, without using resource section or … Read more
I figured it out. The solution involves MergedDictionaries, but the specifics must be just right, like this: <UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source=”ViewResources.xaml” /> </ResourceDictionary.MergedDictionaries> <!– This works: –> <ControlTemplate x:Key=”validationTemplate”> … </ControlTemplate> <style x:key=”textBoxWithError” TargetType=”{x:Type TextBox}”> … </style> … </ResourceDictionary> </UserControl.Resources> That is, the local resources must be nested within the ResourceDictionary tag. So the … Read more
You should use System.Windows.Controls.UserControl‘s FindResource() or TryFindResource() methods. Also, a good practice is to create a string constant which maps the name of your key in the resource dictionary (so that you can change it at only one place).
From my archives: This is a useful chess programming wiki. This is a simple introduction to chess programming. This is a (free) book on chess algorithms. This contains several easy step-by-step YouTube tutorial series’ ranging from beginner to advanced level. This is a more advanced introduction. This is Adam Berent’s interesting computer chess blog. This … Read more
This is a path pattern that is used in Apache Ant library. Spring team implements it and uses it throughout the framework. Back to your problem. According to the Javadoc for AntPathMatcher, it only has 3 rules: ? matches one character * matches zero or more characters ** matches zero or more ‘directories’ in a … Read more
You can get the path to the Resources directory like this, NSString * resourcePath = [[NSBundle mainBundle] resourcePath]; Then append the Documents to the path, NSString * documentsPath = [resourcePath stringByAppendingPathComponent:@”Documents”]; Then you can use any of the directory listing APIs of NSFileManager. NSError * error; NSArray * directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsPath error:&error]; Note … Read more