In my java app there is a code which reads the properties file from src/main/resources folder.
Java Code:
@Component("mailerProperties")
public class MailerProperties {
private static Properties properties;
public MailerProperties() {
properties = new Properties();
[Code] ....
Now I need to create a jar file and also remove the properties file from src/main/resources folder and place it outside the jar file(in the same location as jar file) so that data inside it can be changed easily in future.
Question: Currently it uses ClassPathResource("mailer.properties") to read the prop file. What change I need to make to read it from outside the jar file...
Where can I learn or how can I, being the most efficient way known to do so, create a folder outside my JAR file with the java source code, this then will copy YAML documents from my JAR file to that folder, then I need to read the YAML documents some way. I'm making an addon for a game, I am using an API that allows you to make a config.yml easily, and add and read entries from it, but I've read that I need to make my own methods to be able to create additional YAML documents.
I don't exactly know what to type in google to perhaps find such a page, but I did try to find a tutorial page about this or something and couldn't.
I've partially figured out how to create a folder, but I have a problem, how can I RETURN one directory to make the folder, I don't want to make the folder in the JAR file I want to make it just outside the Jar file in the same folder that the Jar file is at.
I'm trying to read images and draw them on JLabel. This code snippet below is reading images from a folder
private ArrayList<ShowItem> getData() { int score = 0; ArrayList<ShowItem> item = new ArrayList<ShowItem>(); File dir = new File(getImageFolderPath()); if (dir.isDirectory()) { for (final File f : dir.listFiles(IMAGE_FILTER)) { BufferedImage img = null; try {
[Code]...
ShowItem is a class that extends Image. DisplayImage extends ShowItem.
One of the overridden methods in ShowItem is
@Override public Graphics getGraphics() { return null; }
I'm not exactly sure what to do here so I left it.
In another class, where I draw the images on Jlabel. This is what I have:
I tried to run it, and check if I'm actually getting the images, and did system out and it listed all the jpg images I have but it's not displaying on the panel.
i want to list files from resources folder like this:
@ManagedBean public class galley implements Serializable { private List<String> list; @PostConstruct public void init() { list = new ArrayList<String>();
[Code] ....
but it give me a null pointer exception on fList .... The directory of resources is :
I'm not too familiar with serialization.It actually I found at this site (Java - Serialization) says that it will write and read properties of an object. I'm not quite sure how this would work as I would have thought that writing it to a text file would just do a toString() when you wrote it, but the page seems to think otherwise, and also names it .ser or something instead of .txt.
I thought, maybe this would work with my idea for a notepad that could store a Font, font color, and other settings, for the file. It would be beyond normal notepads. However, could you do this for a file as it would store text plus other things.
The upshot of this is that the same file, I was hoping to be able to be read by regular text programs like Notepad. However, could Notepad read such a modified file? Also, if notepad wrote to it, would it destroy my font properties and stuff that I'd add to it?
Also, what does this mean:
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans package. Please see XMLEncoder.
Originally, I was going to use FileAttribute or something like that but it looked hard to do and likely not what I wanted. However, this looks more like what I want, but I'd like to know. This could be a huge breakthrough for a lot of things I was hoping to do but never could think of an efficient way to do.
Update:This serializable thing works great for my text editor but it won't work too hot if another program like Notepad reads it as it will appear like gibberish, including the text.
I had thought of having it make two files, one regular, and one that was serialized, to deal with this, but this doesn't work if I try opening a file that another text editor created that might not have this other serialized version of the file.
Also, I haven't yet tried extending File itself yet. However, I still don't see how it would work the way I'd hoped.
In a way, I want it to be like a RTF with some things used to set te font of the text area when loaded but be able to deal with opening a file made by another text editor and also have another text editor be able to read it even if my text editor created it.
File destHtmlFolder = new File("C:/bea/user_projects/domains/OICDomain/DOC_SERVER/REPORT_HTML_DUMP"); File srcExcelFolder = new File("C:/bea/user_projects/domains/OICDomain/applications/IIMS/IIMS/target/source/REPORT_EXCEL_DUMP");
I have a problem. Depending on one of the request variables, i need to load different properties files. All these property files have same keys, but with different messages. I need to take the user to different sites(though internally, the backend logic remains same...Look and feel of the front end along with messages to be shown change to make the users feel they are being directed to a different site).
I am thinking of loading the properties file from the JSP when the user logs in first time from login page so that these properties are available until the session expires & not read the properties file in Controller.
I am creating a bukkit plugin, but my question has nothing to do with bukkit, just Java. I am trying to load a file that is located in the same folder as the jar file that is being run and I am having no luck. I can't set a manual path because if I move this plugin to a remote server it won't work. So how to get a file from the same folder as the jar.
The code for my button is below - I know it is wrong and that I need to change line 8 at least,so I am technically asking the property object if there is a key_name there but I dont quite get how to do that
//code for button
JButton btnSearch = new JButton("Search"); btnSearch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //find selected command String key_name = textFieldSearch.getText();
[Code] ....
I basically just want the user typed in word to be checked against a keyword in a properties file and if it exists, pull the key and the value back into a panel
and, have a response class file, which is setting a response from database to display it on `JSP` file. The value that I am getting from database is in the form of `code` or `integer`. I needed to have that value from the database and before setting the response I need to use `getProperty(code)` and save the String representation of that code into a new list and then pass that list to `setResponse`. For e.g: This is the value I am getting from database:
col1 | col2 | col3 | 1 helo done
I needed to show on my JSP page as:
col1 | col2 | col3 | USA helo done
I was following this tutorial [URL].... but not able to exactly understand how to achieve the same.
This is my `DAOImpl` where I needed to `iterate` and save the `mapped key-value` in a new list and then pass to `JSP` page
public class CountDAOImpl implements IDataDAO { private Connection conn = null; private Statement statement = null; private ResultSet rs = null; private List<String> country_code = new LinkedList<String>();
The code for my button is below - I know it is wrong and that I need to change line 8 at least,so I am technically asking the property object if there is a key_name there but I dont quite get how to do that
//code for button
JButton btnSearch = new JButton("Search"); btnSearch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //find selected command String key_name = textFieldSearch.getText();
[Code] ....
I basically just want the user typed in word to be checked against a keyword in a proeprties file and if it exists, pull the key and the value back into a panel ....
I'm currently working on a java project simply to learn java. So far, it creates a window and makes a properties file, or appends data to it if it already exists. The problem is that I'm not quite sure how to check if the file already exists to append data to it. I'm currently using a boolean (configCreated) that appends data when true, and creates a file when false. The problem is that this boolean is always false since it's at the beginning.
When we have a property in the jnlp file that has accented characters (i.e. Mañana), the System.getProperty() call is returning null. This is working fine with Java 7 Update 40, and accented characters in the <information> section of the jnlp file are working fine under Java 7 Update 45, but not in the <resources> section.
I need to write the exact directory path like C:LisaestUpdate to a properties file.
I am trying it by
FileInputStream in = new FileInputStream(test.properties); Properties props = new Properties(); props.load(in); in.close(); FileOutputStream out = new FileOutputStream(newprop.properties); props.setProperty("myDirectory","C:Lisa estUpdate" ); props.store(out, null); out.close();
but the properties file is updated as C:Lisa estUpdate
Extra comes before :.
How can I remove that.
Even I tried it with an command but got same output.
I have a properties file with key values in it, now when I use my search box to search for a key in the properties file to check whether or not it is there - I can't get it to check and return the key value if it is theere. I've tried a few methods but keep getting a null pointer exception when it hits line 15 in the code all the time so I'm stumped at the minute.
I need to execute a perl file from a resource folder, So that i can able to run the perl file after changing the project to a jar file. And also i need to pass an argument also.
I'm currently new to java and I would just like to ask if Socket is sufficient for this file transfer app I'm planning to work on.
The specs are as follows:
~ Move/Copy Files of selected folder/s to a single folder(consolidating them) within the same machine and Network ~ File type will be specified on GUI and those specified will be the ones transferred ~ option to choose Move or Copy of files ~ ability to create/select folder of transfer destination
In our currenr project we have a requirement to open a local/network driver file/folder using JSF 2.0 <h:outputLink> in Firefox browser find the below sample code & correct it, how to achieve the above requirment
Means like in php we can install xampp and there for a new app we need to create a folder in htdocs folder...and after that , that folder works like a app.
I'm working on an application and I would like to package my resources (icons, about dialog images, splash screen images, release version text, etc.) in the jar file I'm going to distribute for deployment. I would like to access these resources from the JAR file in my deployed code. But I would also like them accessible when I'm running the code in my Eclipse IDE. Is there a way to do this using only one code base?
My Eclipse project structure is src (folder) which contains my source code, bin (folder) which contains my class files and res (folder) which contains my resource files.
I am using the javapackager utility to create my deployment JAR and build a self-contained deployment .exe for deploying to Windows.
Is there a way to have the javapackager build a single JAR file from multiple sources (i.e. my bin and res folders)? What do I have to do in my code so that the same code can be used to load resources when I'm running in Eclipse and the self-contained deployment?