473,605 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to copy a file from windows to linux using java

42 New Member
Good Day:
as the title says i am creating a program that will copy a file from windows to a linux machine. any help would be appreciated. i tried looking for it on google but i dont see a real help.

a sample code will be a huge help.. ive tried a few times but to no avail and im running out of ideas

thanks in advance
Jul 3 '08 #1
9 9963
r035198x
13,262 MVP
Open a Socket and copy the file as an InputStream.
Jul 4 '08 #2
akoymakoy
42 New Member
Open a Socket and copy the file as an InputStream.
Im sorry but i dont know what sockets are... pls help me..
a link to a tutorial on socket programming might help.. or a sample code will extremely help..
Jul 6 '08 #3
JosAH
11,448 Recognized Expert MVP
Im sorry but i dont know what sockets are... pls help me..
a link to a tutorial on socket programming might help.. or a sample code will extremely help..
Take a step back: how are those two machines connected to each other? Can
one machine 'see' the filing system of the other and/or vice versa? If so, you can
simply copy the file from one FS (Filing System) to the other.

If not, does that Linux machine run FTP (File Transfer Protocol)? If so you can
use your FTP client on the other machine to transfer the file.

Does a SMB ("Samba") server run on that Linux machine? If so you can go back
to that step one again and simply copy the file.

Does any service run on that Linux machine that accepts file names and data
and creates a corresponding file and stores the data in there? If so you have to
connect to that service and send it the name and content of your file. This
usually involves sockets.

Is there any wire connected between the two machines? If not, you're out of luck.
Use a USB stick or even floppy disks then.

kind regards,

Jos
Jul 6 '08 #4
akoymakoy
42 New Member
If not, does that Linux machine run FTP (File Transfer Protocol)? If so you can
use your FTP client on the other machine to transfer the file.
i guess it runs FTP (Linux)

The machines are connected like this:

im browsing through the web application through IE on a windows workstation

the application is being hosted in a linux platform.

The method im doing is to upload a file from the windows workstation to the linux workstation.

*SCENARIO*
i want to change the picture the front page displays (.../pic1.jpg) .. i then browse and upload a new picture from any terminal (windows for example) and copy it to the directory of the linux.
Jul 6 '08 #5
JosAH
11,448 Recognized Expert MVP
So your Linux machine has a web service available, i.e. the service probably
listens to port 80 for requests. This is old time technology with its myriads of
solutions. Google for "web upload file servlet" and see the results.

kind regards,

Jos
Jul 6 '08 #6
akoymakoy
42 New Member
i would look into it thanks


i would also get back here i f i get it done or not..
Jul 8 '08 #7
akoymakoy
42 New Member
so far all i have seen are jar files that need to be bought or is only in trial versions... are there open / free web upload file servlet. ?
Jul 9 '08 #8
JosAH
11,448 Recognized Expert MVP
so far all i have seen are jar files that need to be bought or is only in trial versions... are there open / free web upload file servlet. ?
You didn't look close enough: this one is completely free and there are
many more where this came from.

kind regards,

Jos
Jul 9 '08 #9
akoymakoy
42 New Member
Good Day ,
Right now i used the uploadPackage.j ar that i found . If anyone is familiar on how to use this jar pls help me.
When i upload an image file of any type and upload it or copy it to another pc the image file is broken.. the image is distorted..

this is my configuration.t xt:

name=report3.jp eg
dir=c:\
log=c:\
max=100000000
extensions=
reply=/upload.jsp
error=/tryal.jsp
overwrite=1


the max variable is the only thing i think that i should tweak.. However when i changed it from 10000 to 100000000 .. the image gor better but still distorted...

is there anything i could do or is this jar file limited on a uploading a certain kind of file.?

If there are any more suggested jars to use.. pls do so...

As to the oreilly servlets.. im still trying to study how to use it... i saw the demo but i am in the process of making it to work.
Jul 17 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
12360
by: Hal Vaughan | last post by:
I want to have a config file for my program, which means I need to know where the config file is. If I type: java myclass and it runs myclass.class, is there any way to obtain the location of the file myclass.class? Will this work if it's run from a relative path, like: java ../progs/myclass
4
3001
by: inquirydog | last post by:
Hello- I, the inquirydog, would like to solicit suggestions for a new web page I am making: I am creating a simple website that will translate concepts between windows os's, Linux, and the Java language with all of its related technologies. The website is at http://members.dslextreme.com/users/inquirydog, and is a mock-version of the Rosetta stone, which indicates concepts from each "platform"
48
8458
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential problem. The program may crash unexpectedly while writing to the file. If so, my program should detect this during startup, and then (during startup) probably delete the data added to the file and redo the writing operation.
12
4159
by: Von Clubusev | last post by:
I like Java just as much as I like C#, but the truth is that unless you absolutely need platform portability, DotNet is the way to go. This is becoming even more true with the release of Windows Vista later this year. Users will quickly get used to the flashy Mac-Like UI of Vista and expect all their apps to support Vista specific features. Java will try to play catchup but but the UI will stll be primitive compared to .Net, and it...
3
2331
by: Igor.Smirnov | last post by:
Hi, Why g++ in Linux does not call copy constructor at return statement? I have detected this at Sicentific Linux 4.1 (g++ v. 3.4.3) and Red Hat Linux 8.0 (g++ v. 3.2). Microsoft Visual Studio C++ v. 8 at Windows XP calls them as necessary (as should be according to Stroustrup and my previous experiense), that is it calls the copy constructor for the object, returned by
3
3764
by: muquaddim | last post by:
Hi, First of all I am not a java programmer. what I am doing is just trying to port a precompiled game to other machine. I have a java game project. the final output or the game is "game.jar". I compiled this in fedora with netbeans (5.5.1) ide. It was running well in fedora. But The problem arises when I try to run that same jar file from windows with same command. I used same jdk in both linux and windows. when I run it from fedora #...
5
2792
by: ganeshp | last post by:
Hi , In Java using socket programming is it possible to have a server program on windows that services a client program on linux? I tried the code in the below given link: http://williams.comp.ncat.edu/Networks/JavaSocketExample.htm This does not work when the client program is on a Linux machine. Error: Error Connection refused
1
2590
by: RolfK | last post by:
Hello Experts, I have a small problem with copy of CDATA sections. (I'm using XSLT2.0 ) My output target is defined as txt. In my xml source is a CDATA section to be put as it is into the output text file. This CDATA will be copied to the output by xsl:value-of or xsl:copy- of.
11
4873
by: isaacrc82 | last post by:
Hi every body: An exception is thrown when I open some files in linux, this doesn't occurrs when I do the same in windows XP. This is the pierce of code that throws the exception: 42 public static byte readFileBytes(File file) throws IOException { 43 java.io.InputStream istr = new java.io.FileInputStream(file); 44 byte bytes = new byte; 45 istr.read(bytes); 46 istr.close();
0
7937
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8423
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8076
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8290
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6749
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3913
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3960
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1546
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.