I am copying the xml files from one folder to other folder, in the source folder, i have some files which have some content like "backing File="$IDP_ ROOT/metadata/iPAU-SP-metadata.xml" but while writing to the destination folder.i am replacing the "$IDP_ROOT" with my current working directory. The entire copying of files is for deploying into tomcat server. The copying is done only when server starts for the first time.Problem: If i change the folder name from my root path in my machine after i run the server,the entire process will be stopped because the destination folder files already contains the content which is with existed files names or folder names.
So i want to change it to relative path instead absolute path. What is the best way to do it? Please look at code below:
[ // Getting the current working directory
String currentdir = new File(".").getAbsoluteFile().getParent() + File.separator;
I'm a Java beginner and I've been trying to scan a file using the Java Scanner. I've tried searching online for this error and I only find people's questions who have entered an incorrect relative path. I'm entering in an absolute path and I'm using Eclipse Standard Edition on a 2013 MacBook Pro with Mavericks 10.9.2.
Anyway, the error message I'm receiving on Eclipse is: Exception in thread "main" java.lang.Error: Unresolved compilation problem: Unhandled exception type FileNotFoundException
at App.main(App.java:12) public class App { public static void main(String[] args){ String fileName = "/Users/Student/Documents/index.html";
[code]...
Why it cannot find this file. I've checked the absolute file path of index.html on my Mac and I've copied and pasted it into my code.
All I want to do is load an image into a swing JLabel and display it, but I'm going to have to make a JAR of the program and submit it for grading, so I need to be able to get the path of the image file relative to the JAR (at least I think that's how it works - I've never made a JAR before. Right now I'm just trying to load it from a path relative to my netbeans project). I've tried at least 20 different combinations of paths, file locations within the project, etc., but nothing works.
Anyways, here's the test class I've been using to try to figure this out in its current iteration. Right now the image I want to load is in src/resources and the class is in
src/imagedisplaytest package imagedisplaytest; import javax.swing.*; import java.awt.*; public class ImageDisplayTest extends JFrame { private JLabel testLabel; public ImageDisplayTest()
I done a small application with Javafx that start an Embedded Jetty. All works fine in Windows also with native package. Instead in Mac it works only before native packaging. Seems that the problem is how relative path are considered.
The tree of the content is this: myfile.jar webapp (folder) libs (folder)
Look at this code:
String webAppDir = "webapp"; File f = new File(webAppDir); log.debug("Path webapp folder: " + f.getAbsolutePath()); if (!f.exists()) throw new Exception("The folder " + f.getAbsolutePath() + " doesn't exist");
[Code] ....
The problem is that before the packaging in Mac the relative path is that where the main .jar is located an so the code works because the webapp folder is found. Instead after the bundle the path became /Users/MyUser/webapp and of course the folder is not found because it is bundled inside the file.app near the libs folder.
filePath = file.getAbsolutePath(); file = new File(filePath); streamResult = new StreamResult(file);
But it also didn't work. There I got message seems like: "Can't find resource /User/user1/Desktop/program1/resources/file.xml" - but that's really absolute path to a file.
I also made unit test which completed with "green light", but in jar its wrong with message "Can't find resource /User/user1/Desktop/program1/resources/file.xm" ....
I have the Java Development Kit downloaded in my C file and my book tells me to compile the program I need to open command windowand change the directory where the program is stored. I tried the command cd to change directory and received this message "The system cannot find the path specified."
I checked the Environment Variables on Windows 7 and the Path says: C:Program Files (x86)Javajre1.8.0_31in
This is after many tries and i still can't change directory and i keep getting the same message.
I have BlueJ installed on my computer and it does the job of compiling the java source code written in it. If I want to write and compile source code outside of BlueJ do I still need to download the Java SDK and set the PATH variable, even though I am apparently able to do it in BlueJ?
which works fine. The only issue is that I had to place this in the login page. Is there a way I can only set the path to the base url upon server start up?
I have the Java Development Kit downloaded in my C file and my book tells me to compile the program I need to open command windowand change the directory where the program is stored. I tried the command cd to change directory and received this message "The system cannot find the path specified." I checked the Environment Variables on Windows 7 and the Path says: C:Program Files (x86)Javajre1.8.0_31in
This is after many tries and i still can't change directory and i keep getting the same message.The book I am using to learn Java is "Java How to Program: Tenth Edition" from Paul and Harvey Deitel.
I've just got a new computer and i tried to set the class path the way i did with windows xp but it's not working. This is what i have done. I added a Path variable to user variables and added C: Program Files (x86)Javajdk1.6.0_20/bin as the variable value. But when i got to command prompt and type javac HelloWorld.java it just tells me javac is not recognised as an internal or external command.
Also another problem is after trying this and it not working i tried to add a path to the system variables. I added a new path variable but i think once i did that it deleted the one that was already there. Is that going to mess up my computer? What the default path variable for windows 7 is?i've got the right destination as i typed cd to change directory and when i typed C: Program Files (x86)Javajdk1.6.0_20/bin it changed to that. And i noticed if i typed in the destination wrong its just made an error.
I'm working on a project right now in JavaFX, and got stuck. I am drawing a path consisting of CubicCurveTo's and I wonder if there's any way to get the X and Y coordinates from certain parts of that path.
Imagine following a curve (path) with a pencil slowly, and every second you take note the X and Y coordinate. I mean I'm not interested in the control points or start and end points, but the points "in between", preferably at a certain interval.
I've searched for many things online, but have trouble knowing exactly which words to search for. "Paths" often bring up file paths, traversing, coordinates etc. all fail to give me any good results.
I tried to be as specific I could, and I don't think my current code is of any interest in this matter.
(The point of it all is that the path should simulate the path a person walks, and I will store the coordinates in a database for every second).
I want to use the bit of code below to re-write the page to tell the user of a successful registration and then redirect them to another page. My problem is that I can't figure out how to get the path right for the login page. As can see, my first choice was to have the use click to the login page and when I use href it works fine.
I tried to use the entire file page starting at C and that didn't work. I also tried
${pageContext.request.contextPath}/Login
which is what I had to do for the action in the form for the login servlet page.
My question is what is the URL I need to use. By the way, if I jut put in google's URL, or any other for that matter, it works fine.
I was asked to create an Android App with SQLite Database. I had referred some example and tutorial which can be found from the internet but 1 thing that is still unsolved.
The default path for Android SQLite is //data/data/<Your-Application-Package-Name>/databases/<your-database-name> which can be found in Eclipse DDMS after connecting the phone to the computer or the emulator is on.
I had tried many example and tutorial and yet I can only access to "data" file only and the rest (/data/<Your-Application-Package-Name>/databases/<your-database-name>)are never appeared on my screen. This is one of the website (URL....) I learnt to create my database app.
I had follow the steps exactly for many times but I still can't find the path. The app is running fine as it will show saved data/"contact" although I restart the apps(Which mean it did save my data but I just can't find where did it saved). What's wrong with my Eclipse?
After install when i run sqldeveloper command then it prompt me for jdk path
1. Which I don't know how to find 2. When I try to give /usr/bin/java1.7.0_09/ and enter then it give me below error
/usr/bin/java1.7.0_09 Error: /usr/bin/java1.7.0_09/bin/java not found Type the full pathname of a J2SE installation (or Ctrl-C to quit), the path will be stored in ~/.sqldeveloper/jdk
I have some N*M matrix or N*N matrx , and there's a "worm" that can start from any index in the first column, or, any index in the first row. i need to choose the longest worm that satisfying this :
The index that comes after the index before him must be greater then 1. and i must use recursion, also for helper methods. no loops at all. that's it. i'm having a problem to find the longest worm in the matrix.
My idea was to create an helper array and assign to the array indexes a variable that will count the steps of the worm and finally assigns in to the helper array index. then i used findMax method to find the max value in an index. and thats will be the longest worm. i wrote a lot of code so i wont put it here. i will say that i'm close. if the longest worm is 6 i get in my output 7.
First of all, i am using ubuntu and jdk8. My problem: displaying the current path of a file in my system Approach: I have a file called dummy.txt in a given directory which have enough permissions and i did the following:
I expected to see displayed the current path of the file without the name of the file but it is showing a different path. I just want to display the current path of the file without the name.
I have a 2D array that is of type int[][]. it is populated with 1's and 0's. I need to create a method that allows me to search from the top row finding a possible path to the bottom--the path is a path of connecting cells containing 1. I need to create an array that stores the cells that are needed to be searched. When the search carries out, for each cell stored it needs to check the cells to the left, right, below and above the current cell.
I also need to create a variable to store the current cell. I thought initially it would be an int but it can't be because it needs to hold the the index of the current cell. and any of the cells searched that are an immediate neighbour of the current cell are added to the storage array.
I have these instructions but I am having trouble converting into code
Finding a path through vegetation from the top row to the bottom row: The idea is we will start from a cell in the top row and advance below for as long as we can. Since we are still not done exploring a cell until we have explored ALL it’s vegetation neighbors, we will add the cell to an array of cellsToExplore and only come back to it if the current cell we are examining is fully explored. Here is pseudo-code of the algorithm !
• Create array cellsToExplore (what size should this array be?)!
• Create an integer count that stores the number of cells in cellsToExplore!
• Go through the top row and add ALL vegetation cells to cellsToExplore!
• Create a variable to store currentCell we are exploring and set it to null.!
• while count > 0 do!
- set currentCell to the last cell in cellsToExplore (last cell added to the array).!
- label currentCell as burning vegetation!
- If the currentCell is on the bottom row then we return true (we found the path).!
- if the cell below currentCell is vegetation then add the cell below to the cellsToExplore array.!
- else if cell to the right of currentCell is vegetation then add the cell to the right to cellsToExplore!
- else if cell to the left of currentCell is vegetation then add the cell to the left to cellsToExplore!
- else if cell above the currentCell is vegetation then add the cell above to cellsToExplore.!
- else remove the currentCell from the cellsToExplore (we are done with this cell). !
Trying to find cheapest path recursively, given a grid a integers trying to recursively find the cheapest path from the top to the bottom. cheapest being the sum of the path. I think I've made my code over complicated. recursive things are usually much more elegant
import java.io.FileInputStream; import java.util.Scanner; import java.io.FileInputStream; import java.io.FileNotFoundException; public class trial { public void readFile(String fileName)