Creating a .bat file to compile .java files
Hi,
I am trying to create a .bat file to compile java files. I have created the .bat in the same folder as teh .java file I am trying to compile. I know the path is set to the proper folder to find the compiler, but I keep getting an error saying the system can not find the specified file, or can not read fileName.java. Everything is spelled correctly, and I know it works because it will compile from the command prompt. Any suggestions?
rather than including a sourcepath, just specify the full location. Using your example, this would read like
javac "C:\Documents and Settings\Kevin\Desktop\School Stuff\AP Comp Sci\PowerPoints\Chapter 02\Executables\Section 2.2\Facts.java"Note that everything is inside the inverted commas " "
I tried this on a hello world Java program inside a brief case and it works fine.
The class file is created inside the briefcase.
If you want to create a bat file to do this from anywhere, modify your batch file to look like this:
c:\
cd "C:\Documents and Settings\Kevin\Desktop\School Stuff\AP Comp Sci\PowerPoints\Chapter 02\Executables\Section 2.2"
javac %1.java
java %1Again, you would use this as follows
mybat FactsDon't forget to leave out the .java extension.
This will compile the java file and attempt to run it for you.
If you don't want it to run, leave out the java%1
If you create other java files in this same briefcase folder you can use mybat to compile them too.
For example
mybat Facts2
Similar Messages
-
How to create a .bat file
Hi,
I want to transfer and run my program on a computer
that don't have JDK. I want to create a .bat file or
something like that. How exactly is this done? I guess
I have to include all the javaclass files that my program
is using. Can I put everything in one directory and than
zip it and create the path in a .bat file?
Please help me I can't figure this one out...Steps of creating a DOS batch file.
1. The machine that will run these Java programs needs the JRE or JDK installed on it. If it is an applet, a web browser is OK.
If you are using just standard core Java packages such as
java.awt.*
java.awt.event.*
java.io.*
java.net.*
(and others... not extension packages such as javax.swing.*, Java 3D, etc)
you may not need JDK and can just use Microsft's JVM which is jview.exe on the windows directory, C:\Windows
2. Create a new directory to store all the Java class files, data files, images and other resources that the program makes use of.
3. Create a batch file that will install and/or run the program IN THE SAME DIRECTORY as the class files.
4. Go into the batch file properties by right mouse clicking on the batch file and selecting properties. Go to the programs tab at the top and look at the 'working' and 'cmd line' properties. These two need to be blank. If there are any values in there, then delete them.
5. Zip the directory using WinZip and then create a self-extracting executable. (Just right mouse click on the directory and select the 'Add to zip' option).
6. Save to a floppy or another location.
Here is a sample batch file:
(Assumes that the directory with all your files is called myprog and is saved on the floppy disk
Your program that has main method is called Main)
rem -----start batch file--------
@echo off
cd c:\
mkdir myprogs
cd myprogs
copy a:\myprogs\*.* .
echo all done!
echo running application...
java Main (or jview Main)
rem -----end of batch file--------
If you are using UNIX/Linux then a shell script needs to be created. This is then executed by using the commands:
sh <myshellscriptname>.sh
Hope this helps!
Rizwan -
How to create a bat file by abap?
hi~
i ask a elementary question.how to create a bat file in my local pc?how to write some message in this bat file ?thank you !execute bat-files
Reward Points if it is helpful
Thanks
Seshu -
Creating windows .bat file from within an oracle .prc or .sql file
I am currently converting a series of batch jobs on a windows server to use an Oracle db rather than a MS sql server db. In ms sql, I could call \mssql80\binn\isql and it allowed me to pass in .prc files and have a .bat file returned. the .bat file is then executed in the calling bat to set variable value returned in the sql call...
I am thinking I can spool a bat file, however, i do not know how to populate this file with the literals and query values needed to create the bat file which sets values used for further processing in the original calling bat file...
Does that make sense? any help is greatly appreciated.Hi,
There can be various ways to do this.
First and simple way is simply spooling out the batch file. Suppose you have a .sql file with all the queries, run the .sql from DOS prompt like this,
c:\> sqlplus -s username/password@tnsname @mysqlfile.sql
the contents of mysqlfile.sql can be,
rem ---------------------
set echo off feedback off head off
spool c:\batch_files\mybatch.bat
select 'start \w ' || win_app_name from mytable ;
spool off
rem ----------------------
exit
So, you can get the batch file created with desired name in desired directory. The '-s' mentioned in the sqlplus command is important.
There is another difficult/tedious way, but that can give you exact output. With UTL_FILE package you can write an operating system file from pl/sql code, stored procedure/package. Its look more like C-language code, but is usefull. So, write a sql or stored procedure and create the batch file. For that matter, you can write any type of file, just you can write whatever you want to a file.
Cheers -
How to create a .bat file to run *.class files?
Hello.
I have compiled java *.class files.
I would like to make a shortcut on my desktop to run my Java programs.
How to write a shortcut (.bat file or something else) to run Java programs?
Thanks1) Make it into an executable jar file (internet search for "java executable jar" will give you lots of help)
2) Write a batch file. If you do not know how to do this, a Java forum is not the place to find out. Do an internet search or find a windows support site. -
Creating new BAT file script to stop, restart and disable S I agent
We have just installed BOXI3 and are in the process of updating some bat files for stopping, restarting and failover (to our backup servers)and disable services on the Central Configuration Manager. In my old scripts we called each service Examples (
sc
servername.net config "bobjspcengine" start= disabled
sc
servername.net config "BOBJWebiServer" start= disabled)
I have a few questions
1. Server Intelligence Agent... Where would I find it's name like the BOBJWebiServer example?
2. If my bat file stops this agent does that automatically stop the CMS, Webi, Report services?
3. This is for our support team in order to easliy stop Tomcat and other services for failing over to our DR sites and backups since the script automatically stops, starts, restarts disables and enable services..., is this the best approach? We put these bat files out on the servers and all they do is click on them to start the failover process.Try using
Process Monitor for looking the key.
For example, you may set the required value through the group policy and see what windows registry keys are changed. -
How to create a Batch file for java application ?
HI,
How to create a Batch file for java application ?
And whats the use of creating batch file ?
Thanks in advance[http://static.springsource.org/spring-batch/]
Assuming you want to develop a batch application rather than actually just create a .bat file .. -
How to create a .exe file for a java application
Hi, I want to create a .exe file for a java application I am developing so that I can schedule it to run at a particular time using Windows Scheduler on WinNT. Is there any way to accomplish this? Or is there any other way in which a Java application can be scheduled to run at a particular time on Windows everyday?
Create a .bat file and run that. Just have, in the .bat file:
java YourClassName Alternatively, you can use javaw YourClassName (without *.bat, just put it into Windows Scheduler like suggested above).
using javaw won't pop up any window... -
How to get the erroe message, if i run java program using .bat file
Hi,
I have a java file which accepts two inputs as command line argument. I want to make this pgm a tool. So have created a *.bat file which has the following command
java myprogram arg1 arg2
I'm gonna share this program with others. So i'll keep the class file and the .bat file in a commaon folder. All the users have to do is, edit the .bat file to give his/her args and run the .bat file. The pbm is, if the user input is not valid, I have put displays in the pgm to show it.
But if i run thru .bat, I'm not getting the error message or I don't know where it is getting displayed.
Can anyone help me with this ?
Thanks,
MaryWhen i run from the console, I can see the output.
But, when i double click on the .bat file from the
folder, it runs fine and i couldn't see the output.
nullThat's because the error message is printed, and then the console is closed. The message is there but you need to read really really fast :) -
Java virtual machine error: in running bat file!!!
Hi experts!
I have encounterd a problem . Could not figure out why I am having this. I hope at least I will get a clue /suggestion from any of you.
I am creating a bat file from my java Application. Then I double click on the newly created bat file to run that. It gives me Java virtual machine launcher error:" could not find the main class, Progam will exit". I have a VB script, that also create the same bat file. but I dont have problem running that file manually. Even if I create the bat file manually(by typing), it ran well. It shows the error mesage only when I create bat file from my java Application. Instead of running the bat file manually, I tried to run it through my java application too(by Runtime.exec() ). But it shows me the same error msg.
Why am I getting java virtual machine launcher error when I tried to run my bat file that is created from java Application? ANy clue? Please suggest me about how to resolve this.
RegardsProbably because (despite what you say) the contents of the bat file created by your Java application aren't the same as the contents of those other bat files.Yes contents are same. I create the bat file from my java Application. then I am trying to run that bat file manually. It gives me the specified error. But if I create the bat file manually (with the same content) and then run it manually. It works well.
Any clue/suggestion -
Problems running bat file with calls to java programs (.jar)
I created a bat file with calls to jar programs. In each line,
I put a call to the programs with parameters, but bat only
executes the first line and ends execution.
All lines of my bat file must be executed.
What should I do?
Best Regards,
Pedro Felipe
[http://pedrofao.blogspot.com|http://pedrofao.blogspot.com]
[http://viajantesmundo.blogspot.com/|http://viajantesmundo.blogspot.com/]user8730639 wrote:
I realized that the problem isn`t my bat file. I made tests calling another jar files and then all the lines of the batch file were executed. So, the jar file called on my previous bat is finnishing the execution. I verified and the jar apps worked without error.
I would like to know if exists any command in Java that can cause this effect (close a batch), to modify the open source code of the application.Not that I know of.
Is prism a bat file?
If you are invoking bat files from your bat file without using call that would explain it
:: mymain.bat file
:: call the first bat file
call prism.bat arg1 arg2 arg3
:: call the other bat file
call prism.bat arg4 arg5 arg6
:: -
Its not a really java question (its a bat file question)
hi all,
I created one bat file like below
start java.exe -mx50m -classpath ".\SerialConnection.jar" spc.SerialConnection.SECSConnection
its working
but I would like to want if I open the bat file I want to disappear the dos window..
if anyone knows please send the solution
thanksDoes :
java -mx50m -classpath ".\SerialConnection.jar"
spc.SerialConnection.SECSConnection &
work ?No because that's Unix shell syntax which does not work in Windows.
Jesper -
Executing a .bat file from java code
Im writing a utility and i need to be able to create and execute a .bat file from my program. I can create the .bat file fine but when i try to execute it nothing happens. I tried to use the following line of code to try to execute the .bat file (called make.bat) :
try
String parameterString = "\"C:\\WINNT\\System32\\cmd.exe\" C:\\ITS_Test\\make.bat";
Runtime.getRuntime().exec(parameterString);
catch (Exception e)
System.out.println(e);
The Runtime.getRuntime()exec() method worked fine when trying to execute an excel file but for some reason it dosen't want to work for the DOS prompt. Any ideas?Thanks everyone for all the replies.
I have tried all the above with no luck. Im using netbeans, does anyone think that it could be a problem with the IDE.
I tired the following code :
String parameterString = "cmd.exe /C \"C:\\ITS_Test\\make.bat\"";
Process pr = Runtime.getRuntime().exec(parameterString);
pr.waitFor();
This code does not throw any exceptions but just hangs. I also tried:
String [] parameterString = {"cmd", "/c", "C:\\ITS_Test\\make.bat"};
Process pr = Runtime.getRuntime().exec(parameterString);
pr.waitFor();
and:
String parameterString = "\"C:\\WINNT\\System32\\cmd.exe\" \"C:\\ITS_Test\\make.bat\"";
Process pr = Runtime.getRuntime().exec(parameterString);
pr.waitFor();
with the same result. Does anyone know why it just hangs and nothing happens (no exceptions thrown)? -
I'm trying to dynamically create a '.bat' file within SSIS and to execute it. I know how to execute it, but would anyone have an example of how to create it?
File.CreateText Method
Create a .txt file if doesn't exist, and if it does append a new line
Regards!
SERGIO SANCHEZ ARIAS -
I want to know how to create a bat file...plz
Use a simple text editor
Type in DOS commands just like you would on the command line
You can do a google search for bat commands to find a bunch of useful things to use to close the DOS window or other neat things you might want to do.
(assumes you are using windows, can you use bat files in Unix? )
Maybe you are looking for
-
Erro impressão DANFE - IE e ST da J_1BSTAST
PessoALL, Estou com um problema um pouco crítico... será que alguém pode me ajudar? O programa de impressão da DANFE não está extraindo a informação de Inscrição Estadual de Substituição Tributária da tabela de customizing (J_1BSTAST). Precisamos faz
-
I can't find the download for Adobe Photoshop Elements 13 on my Macbook Air. Where else could it be?
-
PUSHing through a DIALOG response NON-interactively
Letu2019s say I have a workflow awaiting a dialog step decision from a user. For simplicity, lets say the possibilities are 1 u201CChoice Au201D 2 u201CChoice Bu201D 0 (for completeness, leave in inbox). Letu2019s say that the item is a
-
How can I download the trial version of Adobe Premiere Pro CS4
Can anybody tell me how can I download Adobe premiere Pro CS4 trial version for windows 7 English.
-
ScrollPane component smooth scrolling
Hello. I just started working with AS 3.0 and I'm yet learning basics. I searched google and couldnt find the answer to my question; How to make scrolling on ScrollPane component smooth with AS 3.0? Please help.