JSF :: Copying File From Server To Remote Machine
May 21, 2014
I am developing a web application in java(JSF 2.0 - Prime Faces). I need to do below operation. My appllication is running on WLS server. WLS is deployed on a server(say Machine-X). In my application i have a requirement , where i have to copy file from Machine-X to another Machine-Y. The Machine-Y is access restricted.
When i tried to copy the file from my app, getting no access exception. I have full control over Machine-Y. We cannot use SFTP as SFTP cannot be installed on target machine(Machine-Y). Robocopy is failing for some use cases. Is there any other way we can copy/write file from one server to other by providing userid/password in java
View Replies
ADVERTISEMENT
Mar 3, 2015
From java running on Windows, I need to access a file on a remote Ubuntu machine. I use the following:
URL U = new URL ( "http://" + SERVER_IP + ":" + SERVER_PORT + "/" + ClsName + ".class" );
where:
SERVER_IP is the Ubuntu IP address obtained from any site that shows the IP address of the machine you are using.SERVER_PORT is the Ubuntu port where the server is listening.
Now:
Do I need to modify this code any further?Do I need to configure the Windows and/or Ubuntu machine(s) for this to work?
View Replies
View Related
Apr 11, 2014
I have developed a code to connecting remote windows M/C from local M/C by using SSH2 (ganymed-ssh2-build209.jar) API. when I run the code its giving below error. Is there any other way to connect remote windows system using java code.
Exception.
java.io.IOException: There was a problem while talking to <host name>:22
at ch.ethz.ssh2.Connection.connect(Connection.java:642)
at ch.ethz.ssh2.Connection.connect(Connection.java:460)
at Connect.RemoteServer.ConnectWindowsServer.runCommand(ConnectWindowsServer.java:55)
at Connect.RemoteServer.ConnectWindowsServer.main(ConnectWindowsServer.java:27)
Caused by: java.net.ConnectException: Connection refused: connect
[Code] ....
JAVA Code
import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.Session;
public void setAuthenticationInfo(String hostname, String username,String password) {
this.host = hostname;
this.userid = username;
this.password = password;
this.recentCommand = "";
System.out.println("setting authentication info completed for host=" + host );
[Code] .....
View Replies
View Related
Jan 30, 2014
I am trying to connect a remote machine but I can't. There is a shared folder in the remote machine, when I write the path to file browser in local machine, it does not find the path specified. Both machines have successful network condition and ping each other. Also, the shared folder is opened to everyone, there should not be a permission problem, right?
View Replies
View Related
Jul 27, 2014
I am developing a web application using JSF-2.0 on weblogic 10.3.6. I am using Facelets as VDL. I have 5 different machine. They are different according to their OS and their geographical location. On my first xhtml page server (machine) is decided. Then on next page file upload and rest of processing takes place. My restriction is that SSO configuration can be done on only one machine.
So I am restricted to using xhtml files from only my primary server where SSO configuration is done. But I have to connect to servlets or managed-bean of different machine as requests are machine specific and file needs to be uploaded to those machines for processing. So I cannot use redirectUrl as I need to be only on one machine. Is it possible that xhtml on one server can talk to managed-bean on other server(different machine)?.
View Replies
View Related
Jan 15, 2015
I'm working on an application I made a few years ago. At that time I connected to a local database so my address was 'jdbc:mysql://localhost:3306/'. That database is long gone so I recreated it on one of my hosted servers but I'm a little unsure of how to connect to it. At the moment I'm trying "jdbc:mysql://www.mydomain.com:3306/" but it is giving me an access denied error.
java.sql.SQLException: Access denied for user 'myusername'@'c-[my-ip].hsd1.pa.comcast.net' (using password: YES)Every result on Google seems to use localhost so I'm having a little difficulty figuring out the correct format.
View Replies
View Related
Dec 14, 2014
a direct solution for connecting a remote Unix server through telnet connection from java application.
View Replies
View Related
Apr 10, 2014
I am trying to check SFTP connection to remote server using enchanter jar. Mine is not a multi-threaded application. PFB sample code...
.....
SSH ssh = new DefaultSS();
ssh.setTimeOut(10000);
ssh.connect("myserver","myusername","mypassword");
ssh.sendLine("cd /u");
ssh.sendLine("sftp -B batch.file utodldse@claoesdsdd.com");
ssh.getLine();
.....
note - the batch.file contains only 1 statement. Please find below.
---
bye
---
But the above program is getting is stuck at times when the server is not responding. It goes into infinite hung state.
Is there some alternative ways to set timeout ?
View Replies
View Related
Aug 9, 2014
I had some questions about a theoretical java program. Say you had a java program on a linux server/pc that referenced a folder on that server. And say you had a Client PC (Windows) that had a share folder to that java program.
If that windows client PC tried to run the program would it run (with a GUI if it had one) and would the main directory of the java program still be on the linux server or would it be on the windows computer since that is the computer that is running the program?
Basically I have a program I am trying to find the best way to run it remotely on a windows computer but it references files on the linux server it is located at and needs to put files it creates there as well. I am just trying to make sure I understand my theory here on how the program will run if it IS run remotely.
View Replies
View Related
Dec 27, 2014
[code=java]
public static void main(String[] args) throws FileNotFoundException, IOException {
// TODO code application logic here
FileReader fr = new FileReader("gautam.txt");
BufferedReader br = new BufferedReader(fr);
[Code] ....
Whats wrong with this code?
View Replies
View Related
Jun 10, 2014
Java Code: import jxl.read.biff.BiffException;
import java.io.*;
import java.util.*;
import jxl.*;
import jxl.write.*;
public class MainProgram{
public static void main(String[]args){
try{
Workbook workbook = Workbook.getWorkbook(new File("myfile.xls"));
[Code]...
Not sure why this code isnt working for me, it makes an empty excel file called output, but never copies the contents in "myfile" to that output file. I have Excel 2010 but I saved both of them as 97-2003 workbooks. Am I missing something? Do you have to go cell by cell to copy an excel file with JXL?
View Replies
View Related
Jul 5, 2014
I have a file(source.txt) that contains some texts. Now, the java code is to run through each line in the source file and check if that line begins with a number and if true, copy that line to the destination file(destination.txt). I have the code but I am not sure why I can't loop through each line in the source.txt file. Below is my java code:
public static void copyFile(File source, File destination) {
BufferedReader br;
try {
FileWriter fw = new FileWriter(destination.getAbsoluteFile());
PrintWriter bw = new PrintWriter(fw);
br = new BufferedReader(new FileReader(source));
String line = new String();
[Code] ....
As shown in the source.txt file, there are 4 lines in the file but when the execution gets to while ((line = br.readLine()) != null) , it executes to false.. Why this is so?
below is the source.txt file
12 is a number
Green is bad
5 is not so cool
you are right
View Replies
View Related
Aug 1, 2014
Is there a way I can package a file INTO a jar file from a directory, not the other way around?
View Replies
View Related
Dec 27, 2014
I want to write a java program which would do remote file transfer without using Byte array..how I can get sample code program??
View Replies
View Related
Feb 28, 2014
I have a requirement where I have to send a file from a local system to unix box(present on client side) using java code.I have developed a code that is successfully sending the file from local system to client side unix box (I am connecting to client side unix box using VPN) provided I run the code in my eclipse IDE present in local system. But when I am running the same code in the unix box it is throwing null pointer exception.Might be the unix system is not recognising the local system. Please find the code.
package abc;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Properties;
import com.jcraft.jsch.Channel;
[Code] ....
Error on unix box which I am getting is :-
Inside sftpConnection method
llllllll
fffffffffffff
Connection Successfull
Channel Connection Succesfull
aaaaa
Inside findFile method
Exception in thread "main" java.lang.NullPointerException
at abc.TranferFile.sftpConnection(TranferFile.java:58)
at abc.TranferFile.main(TranferFile.java:21)
View Replies
View Related
Apr 4, 2014
I have a class named Cash shown below
public class Cash
{
//Quanity Field and RetailItem Object field
private int total_units;
private Retail myRetail;
//Create first constructors
public Cash()
{
this(0,null);
[Code] ....
I'm seriously need to understand the concept of making shallow copies and deep copies. My book has shown me that its better to perform deep copies and I have followed that method. if you guys look in my constructor of the cash class
//Create a a constructor
public Cash(int total_units,Retail myRetail)
{
this.total_units=total_units;
this.myRetail=new Retail(myRetail);
Apparently I have field in Cash Class named
Retail myRetail
When I pass in an argument from my demo, I'm making a copy of that object from the demo class. In my retail class, I have the following copy constructor .
//Make a copy constructor
public Retail(Retail Object1)
{
Item_Name=Object1.Item_Name;
Item_Number=Object1.Item_Number;
// if I use this then my program would work//this.cost=Object1.cost;
//if I use this part of code below, my program won't work at all and I would get an error saying Exception in thread "main" java.lang.NullPointerException
this.cost.Item_Cost=Object1.cost.Item_Cost;
this.cost.Wholesale_Cost=Object1.cost.Wholesale_Cost;
}
My question is why can't I perform a deep copy there. I know if I do
this.myRetail=myRetail
in my cash constructor it would work, but then the book says its not a good method;
View Replies
View Related
Mar 4, 2015
I am creating a server that stores application updates. When the client connects the server send the update. The server is sending the file but the file is not complete, i.e, if the file is 317kb,its send 117kb. Below is the code I am using :
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class TestFileServer {
[Code] ....
What could the problem be?
View Replies
View Related
Aug 6, 2014
I have a requirement to get the details of the files present in a directory on a server. I need to get the file names and timestamp. I have the below code to get the file names:
Connection conn = new OracleDriver().defaultConnection();
ArrayDescriptor arraydesc =
ArrayDescriptor.createDescriptor ("DIRLIST_T", conn);
File myDir = new File (dir);
String[] filesList = myDir.list();
ARRAY dirArray = new ARRAY(arraydesc, conn, filesList);
return dirArray;
But am not able to get the timestamp. How can I get the timestamp as well.
View Replies
View Related
Mar 21, 2014
How to allow the user to select several files from one folder in the JFileChooser and copy them in a subfolder in the same folder, or another folder?
View Replies
View Related
Feb 5, 2015
Is it a good idea to have basic code that works such as classes print lines array definitions ect ect in your own library in word or something so you can copy and paste it and then edit it to suit what you are doing or is this a bad idea and you should right everything from scratch...
View Replies
View Related
Jan 25, 2014
I want to create a simple ftp server which can upload and download a single file. i found code from google search but its showing error : connection refused . here is my server code n client code.
//server code
[highlight = java]
import java.io.*;
import java.net.*;
[Code].....
View Replies
View Related
Jun 16, 2014
I have also tried above code with few changes but I got error. Code and error show below.
Java Code:
package practice;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
[Code] .....
Error:
Java Code:
Jun 16, 2014 6:21:33 PM practice.TestFTPProgram main
SEVERE: null
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
[Code] .....
View Replies
View Related
Jun 26, 2015
I am trying to create a new text file in FTP Server using FTPClient but im not able to do. By using storeFile method i can only upload file that is already exists in my local system. But my requirement is to create file directly into FTP Server.
View Replies
View Related
Apr 7, 2014
How do u copy all the elements in an array eg A into another array eg B? This is the question:
An array A contains integers that first increase in value and then decrease in value,
For example, 17 24 31 39 44 49 36 29 20 18 13
It is unknown at which point the numbers start to decrease. Write efficient code to code to copy the numbers in A to another array B so that B is sorted in ascending order. Your code must take advantage of the way the numbers are arranged in A.
This is my program:
This is the error message:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at Quest30.CopyAndSortArray.main(CopyAndSortArray.jav a:16)
View Replies
View Related
Jun 15, 2014
I need to copy my neatbean code to word, (school stuff) now I know this is possible, cause I see it on internet often.
I tryed copying it to notepad++ and then to word... wont work the code will still all black.
View Replies
View Related
Jan 23, 2013
I'm using EJB 3.1 and JBOSS 7.1.. Is it possible to create and write a file(CSV) directly to SFTP server?
View Replies
View Related