JFileChooser-how to execute a file
Hello everyone
i am a newbee in Java and i have a small problem with the JFileChooser. Actually i create one, set the filters and i just
can't figure out how the file i choose will execute. For example
i want to choose a .doc or a .bat file and make them open (run) just
like in Windows. My GUI role is just to manipulate (open, delete etc.) diffirent kinds of files. An example of code opening something like .bat or .pdf would be usefull. Thanks a lot!
Hello everyone
i am a newbee in Java and i have a small problem with
the JFileChooser. Actually i create one, set the
filters and i just
can't figure out how the file i choose will execute.
For example
i want to choose a .doc or a .bat file and make them
open (run) just
like in Windows. My GUI role is just to manipulate
(open, delete etc.) diffirent kinds of files. An
example of code opening something like .bat or .pdf
would be usefull. Thanks a lot!I'm pretty sure JFileChooser allows you to select a file from your system, but it doesn't write, read, save, etc. (basically, do anything with it).
You'd have to write code to run the files yourself- so it's not a problem with JFileChooser, it's just the way JFileChooser is.
Similar Messages
-
APEX: How to execute Script file from APEX
Hello All,
Can anyone tell me how to execute script file from APEX?(Step by Step process)
Thanks & Regards,
Jiten Pansarahttp://docs.oracle.com/cd/E23903_01/doc/doc.41/e21677/sql_rep.htm#AEUTL193
Regards, -
How to execute batch file from JSP
hi frens !
i wanna know how to execute batch file from my JSP.i am using exec() method to get call the batch file. but its not working ....plz help
here mine code:-
File F = new File("C:/var.bat");
try{
if (F.exists())
Runtime rt = Runtime.getRuntime();
String url=F.getAbsolutePath();
Process proc = rt.exec(url);
proc.waitFor();
proc.destroy();
catch(Exception IOEx){
System.out.println(IOEx);
}Thanks and Regards
AllwynYou might improve your chances of getting help if you do two things:
1) Explain what "not working" means.
2) ChangeSystem.out.println(IOEx); to IOEx.printStackTrace(); (in the eventhat is in fact related to "not working"). -
How to execute .sql file in Stored Procedure?
Hi,
I have an urgent requirement, where i have to execute .sql file form Stored Procedure.
This .sql file will have set of update statement. I need to pass value to this update statement.
Kindly please help me.
Regards,
IrfanThis is required as part of Data Migration where i have to do 100 of table's update. Each time update table will defer, so its better to have in separate script file (.sql). Can u paste some sample/syntax to exceute .sql file from stored procedure. I am new to this PL/SQL.
How have you determined that it's "better" to have seperate scripts? I assume you mean the table name will "differ" (and not "defer" - I assume that's just because English isn't your first language? no problem - I think I understand what you're asking).
So what I think you're asking is that you have dynamic table names but each table needs to be updated in the same way?
Question: Why do you have tables with different names that all need the same process doing to them?
Assuming it's a valid requirement (and 99% of the time doing dynamic coding implies it's not).... you could use dynamic code, rather than 'scripts'...
e.g.
create procedure update_table(tbl_name varchar2) is
begin
execute immediate 'update '||tbl_name||' set lastupdate = null';
end;
As you haven't bothered to provide a database version, any example code/data or explanation of what you're actually doing, you're not going to get any detailed answer. Please do take the time to read the FAQ and post appropriate details so people can help you. -
How to execute jar file in java project
hi,
i have made a proj in java in which i have put all my files in a jar file.
can somebody help me how to execute this jar file??
thanksu can put that jar file in ur class path,,
regards
shanu -
How to execute .msi files from java program
Hi friends,
i have written a java program which invokes and thereby execute any executable files like .exe and .bat.
So its working fine with .exe and .bat files, but it is not working with .msi files.......can you please help me how can i execute .msi files as well??
public class Executeexe {
public static void main(String ar[])
try
Process p=null;
Runtime rt=Runtime.getRuntime();
p=rt.exec("D:\\mysql-essential-5.0.83-win32.msi");
p.waitFor();
catch(Exception e)
}here is the programMake sure that the command that's being exec'd works from the cmd line.
Then read this article and do what it says:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
Then if you still are having problems explain what "...it is not working with .msi files..." really means, and provide a [SSCCE Example program|http://mindprod.com/jgloss/sscce.html] -
How to execute a file using jsp or java
hi..
i had a jsp file as front end with start and stop button,
if i click the start button a file on my pc should execute.
if stop button is clicked the file should stop execution.
Any one know how to do this..especially how to run a file in ur system using java..
Thanks in advancethanks for u r quick replies...
Actually i want to run a file on a client machine
only...
Okay.
for example, a client should execute a file which is
in another client...
This is not the same thing as what you just said.
can u tell me the method to execute the file......java.lang.Runtime.exec -
How to execute exe file from pl/sql
How to execute an exe file or an operating system command from pl/sql in oracle 9i.
If it is part of a pl/sql block, use the java suggestion. If you are not in a blck, you can use the "HOST" command. see
http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a82950/ch2.htm#1001697 -
Error : How to execute *.BAT file
Some of the friend said me to execute any file following code
Runtime rt=Runtime.getRuntime();
Process pr=null;
pr = rt.exec("cmd.exe /c start " + "myfilename");
I get error as
CreateProcess: cmd.exe /c start myfilename error=0
Press any key to continue . . .
what is cmd.exe /c start in exec().
Thanks..hi Bhavin
try this code because i had the same problem an d this thing works for me here is the code
// Get file name
String File_Name = // What ever yr file name get as String
// Get Operating System Name
String os_name = System.getProperty("os.name");
os_name = os_name.toUpperCase();
// Declare command as array of string
String[] command ;
// on Windows XP, NT, 2000 command is different and on win 98, 95 is different
if(os_name.indexOf("XP") != -1){
command = new String[] {"cmd", "/C", "start", "\"\"", File_Name};
else if(os_name.indexOf("NT") != -1){
command =new String[] {"cmd", "/C", "start", "\"\"", File_Name};
else if(os_name.indexOf("2000") != -1){
command = new String[] {"cmd", "/C", "start", "\"\"", File_Name};
else {
command = new String[] {"start", "\"\"", File_Name};
try
// Run the commands using Runtime
Process process = Runtime.getRuntime().exec(command);
catch(IOException ioe)
//show Error message
JOptionPane.showMessageDialog((Component) null,
"Unable to Locate the file..."+
"\n"+ioe.getMessage(),
"Error...",
JOptionPane.ERROR_MESSAGE);
}Regards
Satinderjit -
How to execute sql file from servlet
Hi,
I am using JSP, Servlets and Oracle 8i in my application. I want to execute .sql file from java code. Is it possible to do that,
as we execute .sql file from sql plus prompt.
Suppose I have abc.sql file and I want to execute it from java code.
If any body have the solution then pl. reply with sample code.
Thanks,
RajeshIf any body have the solution then pl. reply with
sample code.No, no, dec - s/he doesn't want the actual solution, but the full code!
/k1 -
How to execute .sql file
hi,
i want to execute .sql files in sql plus from a fixed location whether it may be network location or from system drive. so that i can use it from other computers when i will be working on different pc.
so please tell me for network location solution and from drive. by default it fetch from BIN directory
i am using oracle 10g.
thanksHi FRNzzz!! wrote:
if the .sql files are placed on some network place then also i just need to put the path of that directory ? Sure. You can either set up a desktop shortcut for SQL*Plus using the remote folder as the "Start in" location, or (what I usually do) drag the script file into your SQL*Plus window.
Edited by: William Robertson on Feb 26, 2011 2:21 PM -
How to execute .sql file using ODI
Hi All,
I need to execute .sql file using ODI.
I tried @{path}{file} command in ODI procedure selecting oracle technology.but it is failing.
Do any one have any other idea to execute .sql file.
Thanks in advanceOhk...I think you can try creating batch file(.bat) if its Windows & call that from ODIOSCommand.
The bat file should contain scripts which call .sql file using sqlplus & there you can use @{path}{file} format.
See if this helps.
Regards,
Santy -
How to execute ".exe" files using java
Hi,
This is guruvulu,
I have a problem in executing ".exe" files.For Example InternetExplorer.Hi,
You can execute .exe files in JAVA using the following code.
Runtime rt1 = Runtime.getRuntime();
Process pc = rt1.exec("someexe.exe");
you can get the output of the executed exe file in
in = pc.getInputStream(); //this returns a InputStream
hope this solves your problem.
regards,
P.Venkat -
How to execute batch files or command in JSP environment
Hi,
I am new to Java in general and JSP too.
I have an application that uses JSP code i need to make it run or execute a number of batch files that run under command prompt (ms-dos)?
Can you provide me with sample code on how to do this?Simply put, you can't do that.
(Outputs from executing .BATs can be used in a response strings, though.)
Learn Java and JSP/Servlet basics. -
Dear all,
1. I am trying to import a .jar file and execute (run) in eclipse. I know it can be done from command window by java -jar z.jar . But I am supposed to do it in eclipse . I would appreciate your help.
2. jar files are supposed to be executable. But in my premium window vista as well as in XP it doesnot run by double click though I have given the class path. How can it be done?jar files are supposed to be executable.Only if you have a file association for the extension.
Presumably when you double-click the .jar file, Windows pops up the "Open With" dialog. Select from the list or click Browse... and navigate to java.exe (javaw.exe if you are only going to run GUI applications) in the jre/bin folder. Select "Always use the selected program to open this kind of file" and optionally enter a description for the file type before clicking OK.
Note that a console application opened in this way may flash the console window and terminate i.e. the console will NOT remain open after the application dies.
I don't use Eclipse so I can't help on your other question.
db
Maybe you are looking for
-
Can Someone PLEASE Tell Me Why My Muse Site Will Not Work Upon HTML Export?
Sorry for the long title! I've had a few threads going regarding troubles with my Muse site. These issues have been on-going, and once I was no longer able to upload to Fetch—and had to export to html via FileZilla—it just seems the problems continue
-
Error:- Account is block for posting
Dear guru's Please help us to resolve this problem as on urgent basis,Your suggestion and solution is really appreciated by us......... Error:- Account 1333 3333 is blocked for posting While Invoice is release to accounting through the transaction c
-
YouTube doesn't show up in safari
Every time I search YouTube on safari, a blank page is all I see and I tried restoring my iPad 2 twice!
-
Hi, I'm try to run startconsole through an X session forwarded through SSH. My Display variable is correct and the startconsole works on one of the servers but on the other one, I get the following error: #./startconsole java.lang.NoClassDefFoundErro
-
My ipod doesn't complete a sync. It's a video ipod from 2006.
About a year ago it stopped working and has started to again. Now, though, when I connect it to itunes it doesn't stop syncing on its own. Restoring it doesn't help.