|
Hi..
I am using eclipse juno,tomcat6.
I want to read the property file only by name. and path should be my current location.
currenttly i have hard coded the path. "E:\SERENE0121201311\phibro\param.properties". But when i read the current path it shows "E:\Eclipse_Juno" but it should be ""E:\SERENE0121201311\phibro".
Can anyone help me to set application path..
Thanks
|
|
|
|
|
How are you obtaining the current path and why do think it is wrong?
Use the best guess
|
|
|
|
|
File file = new File(".");
System.out.println("Current dir : " + file.getCanonicalPath());
I am using above code to get current path...
this gives output : E:\Eclipse_Juno
but my code is inside : E:\SERENE0121201311\phibro
I need above path?
|
|
|
|
|
It doesn't matter where your code is it is where you start the program from that is the current directory.
Use the best guess
|
|
|
|
|
I have tried many options but could not get.
please let me know what is the best?
Thanks in advance.
|
|
|
|
|
I am using below code and their output in comment (//)
I need this path "E:\SERENE0121201311\phibro" i have code inside this path...
try{
File file = new File(".");
System.out.println("Path 1 : " + file.getCanonicalPath());\
//E:\Eclipse_Juno
System.out.println("Path 2 : " +new java.io.File("").getAbsolutePath());
//E:\Eclipse_Juno
System.out.println("Path 2 : " + file.getCanonicalFile());
//E:\Eclipse_Juno
String path = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
System.out.println("Path 4 : " + this.getClass().getClassLoader().getResource("").getPath());
///E:/SERENE0121201311/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/phibro/WEB-INF/classes/
String s = currentRelativePath.toAbsolutePath().toString();
//E:\Eclipse_Juno
String myCurrentDir = System.getProperty("user.dir")
+ File.separator
+ System.getProperty("sun.java.command")
.substring(0, System.getProperty("sun.java.command").lastIndexOf("."))
.replace(".", File.separator);
System.out.println("Path 5 : " +myCurrentDir);
//E:\Eclipse_Juno\org\apache\catalina\startup
Path currentRelativePath = Paths.get("");
System.out.println("path 6 : "+path);
///E:/SERENE0121201311/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/phibro/WEB-INF/classes/com/crmod/job/impl/XmlRead.class
}catch(Exception e){
e.printStackTrace();
}
|
|
|
|
|
If you know the path that you want then you will need to code it into your program. It is obvious that when you execute your program you are not starting in that directory, so none of the other methods will give you the path that you want.
Use the best guess
|
|
|
|
|
I need to deploy my web site to somewhere else so must know the path of phibro(my website folder name) folder. if i do hard code then it will create problem.. so please let me know if any other way to do it..
Thanks
|
|
|
|
|
I am not familiar with java web sites, but I would assume that there is some property in Tomcat that will give you the correct location.
Use the best guess
|
|
|
|
|
I want simple example code in web service then related websites for studies.
By
R.Ganesh Babu
|
|
|
|
|
If you type that into a google search, you will find all kinds of example code and references.
|
|
|
|
|
Ok, But I want, if you know best websites, you send to me.
Thanks & Regards,
R.Ganesh Babu
|
|
|
|
|
|
|
What have you tried and where are you stuck? "in java" is not much of a description of a problem....
|
|
|
|
|
I used JPanel leftPanel = new JPanel(new GridBagLayout); to contain "JScrollPane, JRadioButton, JCheckBox" (Like this image).
When I click on "Open..." button to add more picture, the JScrollPane will use "m_arrListImageFilePaths" to auto update its items. Controls in "JLeftPane" is still right their position. But when I click on application's "Maximum" button - the controls is repainted, "Normal" button is lay down "JScrollPane" (Like this video). Please help me solve above problem.
By the way, I attached my project which is helpful in your solving.
Thanks all !!!!!
|
|
|
|
|
How to create last 10 recently opened files list using java in netbeans?
|
|
|
|
|
Try some of these links[^]. Basically, it looks like you have to write the code yourself.
Use the best guess
|
|
|
|
|
i want my program run in swing gui and yield can displayed in jtable.
Everybody,plese help me.
import java.io.*;
public class wile {
public static void main(String[]args){
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String cthdata=("Contoh Data");
String nomber=null;
try{
System.out.print("masukan jumlah:");
nomber=br.readLine();
}
catch(IOException ioe){
System.out.println("gagal");
}
int intnumber;
intnumber=Integer.parseInt(nomber);
System.out.println("No\tIsi");
int no=1;
while(no<=intnumber){
System.out.println(no+"\t"+cthdata);
no=no+1;
}
}
}
|
|
|
|
|
You should study this tutorial[^] about swing and its controls.
Use the best guess
|
|
|
|
|
I'm working with Oracle database. I use PHP for my web service and Android as the client which will send blob data to Oracle DB. I use this code
Bitmap imageUpload = BitmapFactory.decodeFile(picturePath);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imageUpload.compress(Bitmap.CompressFormat.JPEG, 60, baos);
byte[] image_data = baos.toByteArray();
String converted_image = Base64.encodeBytes(image_data);
to decode and send it as base64 encoding, then send it to the web service with this code
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("TITLE", title));
nameValuePairs.add(new BasicNameValuePair("IMAGES", converted_image));
json = jsonParser.makeHttpRequest(url, "POST", nameValuePairs);
This is my PHP code to insert to oracle db
if(isset($_POST["TITLE"]) && isset($_POST["IMAGES"]))
{
$title = $_POST["TITLE"];
$image = $_POST["IMAGES"];
$gambar = file_get_contents($image);
$query = "INSERT INTO images (TITLE, IMAGES) VALUES (:TITLE, EMPTY_BLOB()) RETURNING IMAGES INTO :IMAGES";
$parse = oci_parse($connect, $query);
$lob_a = oci_new_descriptor($connect, OCI_D_LOB);
oci_bind_by_name($parse, ":TITLE", $title);
oci_bind_by_name($parse, ":IMAGES", $lob_a, -1, OCI_B_BLOB);
oci_execute($parse, OCI_DEFAULT);
if($lob_a->save($gambar))
{
oci_commit($connect);
$lob_a->free();
}
else
{
oci_rollback($connect);
}
}
The PHP code successfully insert the query to the oracle db, but when I see the record the blob does not show anything because the length of the blob is 0. I will appreciate any help. Thank you.
|
|
|
|
|
Raditya Kurnianto wrote: I use PHP for my web service
This is Java forum.
Raditya Kurnianto wrote: PHP code successfully insert the query to the oracle db
Based on the code you posted I see nothing that suggests that you would know that.
As a guess, given I know nothing about php, I will note that I don't see anything at all that suggests that you actually put data in the blob. You created it, you saved it, but you didn't put any data in it.
|
|
|
|
|
|
I want some details about java Scanners.
-Toywarrior
modified 21-Nov-20 21:01pm.
|
|
|
|
|
This is a programming forum; you need Google. Or, you need to explain in better detail what problem you are trying to solve.
Use the best guess
|
|
|
|