How to pass arguments to Jar
Hi All,
I have a jar file, called rp.jar, if I run java -jar rp.jar, it shows "Usage rp.jar c:/old c:/new", if I just run rp.jar, nothting shows in the command line? why?
in my main
if (2 != args.length) {
System.out.println("Usage: rp.jar c:/old c:/new");
return;
and how do run rp.jar, it will show "Usage rp.jar c:/old c:/new", thanks a lot
Edited by: huangpu on Jun 9, 2009 9:46 AM
Edited by: huangpu on Jun 9, 2009 9:50 AM
Edited by: huangpu on Jun 9, 2009 9:51 AM
I am just curious why
if I run java -jar rp.jar, it shows "Usage rp.jar c:/old c:/new",
if I run rp.jar, nothting shows in the command line? why?
Similar Messages
-
How to pass argument in main function ?
How to pass arguments in main function of one class from another class ?
I don't want to pass argument from command prompt.
I want to try something like this -
class Test{
public static void main(String args[]){
for(int i=0;i<args.length;i++)
System.out.println(args);
class Fun{
public static void main(String args[]){
Test t=new Test("Hello","good bye");
when i run Fun class it gives error.
Suggest me how can i do that.In Fun class main method does not take arguments that is fine. In Test class instead of main method you can have constructor to take input parameters as suggested by BalusC
However, if you want to make your existing code work, you can call (though not appropriate) main() method of Test class from main() method of Fun class (As main() method is static object is not required to invoke this):
Test.main(new String[]{"Hello","good bye"});Here is your code:
class Test{
public static void main(String args[]){
for(int i=0;i<args.length;i++)
System.out.println(args);
public class Fun{
public static void main(String args[]){
//Test t=new Test("Hello","good bye");
Test.main(new String[]{"Hello","good bye"});
} Thanks,
Mrityunjoy -
How to pass arguments from PAPI to the process
Can any one tell me How to pass arguments from PAPI to the process.
The link Creating a new work item instance in a process using PAPI shows how to create instances on PAPI and pass in the variable information as they are being created.
Provide some additional detail if you're interested in seeing how to pass in variable information using PAPI for scenarios other than instance creation.
Dan -
hi, i am facing problem as to how to pass arguments received by my swf file to an .exe that i have created from a C++ project...do i need to tweak the code in the C++ project in some way that it accepts the input from the .swf file?
Hi there and welcome to our community
What you need to do is click the link below, then choose the forum most appropriate to the product you are using. In this forum we discuss the operation of the forums themselves.
http://forums.adobe.com/index.jspa
Best of luck to you in solving your issue! Rick -
How to pass argument to the Java Plugin JVM w/o using the Control Panel?
I want to deploy an applet to be loaded by the Java Plug In
and fix some settings of its Java Virtual Machine.
The JPI Control Panel offers two ways to pass arguments to the JVM,
none satisfactory.
1. while interactive via the Control Panel Window.
This cannot be a solution for a deployed applet.
or
2. by editing the system generated file that stores
the settings of the Plugin Control Panel, using a property
named javaplugin.jre.params.
The problem with this method is that if forces to access
and edit this property file which is stored at various locations
depending the client platform. Then, it may collide with other
settings for other applets.
Is there a way to pass the arguments to the JVM
from within the html file?
Has anyone found a solution to this question?
JPSI am interested in this issue as well.
Did anyone find a reliable way to specify the runtime parameters that should be used by the Java Plug-in in order to execute a given Java applet?
I believe a good place to specify these runtime parameters would be the applet's JAR manifest: only digitally signed applets should be able to set the desired runtime parameters...
Any comments / suggestion would be greatly appreciated.
Regards,
Marco. -
How to pass argument in manifest file
Hi,
I want to pass argument to main class in jar. Is there any option in manifest file.Hmm..
Seems that my sentence above isn't so correct.
It possible to add custom attribute: value pairs into manifest file and
read it later from Java class.
Here is code sample:
public class ManifestTest {
public static void main(String[] args) {
try {
java.util.jar.JarFile jar = new java.util.jar.JarFile(System.getProperty("java.class.path"));
for (java.util.Iterator it = jar.getManifest().getMainAttributes().keySet().iterator();it.hasNext();) {
Object curKey = it.next();
System.out.println("key: " + curKey + ", value: " + jar.getManifest().getMainAttributes().get(curKey));
} catch (Throwable t) {
System.out.println("exception occured: " + t);
} -
How to pass arguments to .sql file.......
Hello,
I want to pass arguments to .sql file which is being called from within a shell (.sh).
suppose this is the line in shell -
${ORACLE_HOME}/bin/sqlplus -s abcuser/abcuser@abc < ${ABCDB_DIR}/A.sql $val >>${LOG}
- now I want to pass '123456' to A.sql
Please suggest how to do that.
Thanks and regards,You can pass parameters to a shell script executing sql commands just like you would any other shell script.
I have a script called test_os_variables.sh:
sqlplus -s "/ as sysdba" << EOF
select '$1' from dual;
EOF
Now I execute my script passing SHAWN as a parameter.
./test_os_variables.sh SHAWN
SQL*Plus: Release 10.2.0.2.0 - Production on Tue Jan 9 08:09:46 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL>
'SHAW
SHAWN -
How to pass arguments from command-line to Point(x,y)
Hi guys, I'm a beginner. i'm trying to figure this out 'how to pass the arguments from command-line to Point(x,y)'. See below is the code that i have written. But it appears eror. Is there anyone can help me to figure this out?
class day5FourDPoint {
int a = 0;
int b = 0;
int c = 0;
int d = 0;
day5FourDPoint rect(Point AB, Point CD) {
a = AB.x;
b = AB.y;
c = CD.x;
d = CD.y;
return this;
void printout() {
System.out.println("Four Dimension : " + a + b + c + d);
public static void main(String[] arguments) {
day5FourDPoint FD = new day5FourDPoint();
FD.rect(arguments);
if (arguments.length > 1 & arguments.length < 4) {
for (int i=0; i < arguments.length; i++) {
FD=Integer.parseInt(arguments);
FD.printout();
}I don't use VBS so this is just a guess based on what I have read in this forum. I think when you are passing an 'array' to javascript it needs to be a variant data type. My guess your arguments are not making it to the javascript because it it the wrong data type.
-
How to pass arguments to a batch file from java code
Hi
I have a batch file (marcxml.bat) which has the following excerpt :
@echo off
if x==%1x goto howto
java -cp C:\Downloads\Marcxml\marc4j.jar; C:\Downloads\Marcxml\marcxml.jar; %1 %2 %3
goto end
I'm calling this batch file from a java code with the following line of code:
Process p = Runtime.getRuntime().exec("cmd /c start C:/Downloads/Marcxml/marcxml.bat");
so ,that invokes the batch file.Till that point its ok.
since the batch file accpets arguments(%1 %2 %3) how do i pass those arguments to the batch file from my code ...???
%1 is a classname : for ex: gov.loc.marcxml.MARC21slim2MARC
%2 is the name of the input file for ex : C:/Downloads/Marcxml/source.xml
%3 is the name of the output file for ex: C:/Downloads/Marcxml/target.mrc
could someone help me...
if i include these parameters too along with the above line of code i.e
Process p = Runtime.getRuntime().exec("cmd /c start C:/Downloads/Marcxml/marcxml.bat gov.loc.marcxml.MARC21slim2MARC C:\\Downloads\\Marcxml\\source.xml C:\\Downloads\\Marcxml\\target.mrc") ;
I get the following error :
Exception in thread main java.lang.Noclassdef foundError: c:Downloads\marcxml\source/xml
could some one tell me if i'm doing the right way in passing the arguments to the batch file if not what is the right way??
Message was edited by:
justunme11 - create a java class (Executer.java) for example:
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Executer {
public static void main(String[] args) {
try {
for (int i = 0; i < args.length; i++) {
System.out.println(args);
Class<?> c = Class.forName(args[0]);
Class[] argTypes = new Class[] { String[].class };
Method main = c.getDeclaredMethod("main", argTypes);
// String[] mainArgs = Arrays.copyOfRange(args, 1, args.length); //JDK 6
//jdk <6
String[] mainArgs = new String[args.length - 1];
for (int i = 0; i < mainArgs.length; i++) {
mainArgs[i] = args[i + 1];
main.invoke(null, (Object) mainArgs);
// production code should handle these exceptions more gracefully
} catch (ClassNotFoundException x) {
x.printStackTrace();
} catch (NoSuchMethodException x) {
x.printStackTrace();
} catch (IllegalAccessException x) {
x.printStackTrace();
} catch (InvocationTargetException x) {
x.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
2 - create a .bat file:
@echo off
java -cp C:\Downloads\Marcxml\marc4j.jar; C:\Downloads\Marcxml\marcxml.jar; Executer %TARGET_CLASS% %IN_FILE% %OUT_FILE%3 - use set command to pass variable:
Open MS-DOS, and type the following:
set TARGET_CLASS=MyTargetClass
set IN_FILE=in.txt
set OUT_FILE=out.txt
Then run your .bat file (in the same ms dos window)
Hope that Helps -
How to pass arguments to a java program.
I want to pass a file name to java program while it is going to execute.
ex: c:\>java <.class> <filename>
so that i have to take that filename into a string. Is it possible? If it is possible please help me.
and how can i check whether the filename argument is given or not through command line argument?public class Program{
public static void main(String[] args){
filename = args[0];
static String filename;
this code is working. But if I did not give filename, and I only give like this
java Program
Then how can i now whether the argument (args[0]) is passed or not? -
How to pass arguments to script from plugin
Hello there....
I want to run a script from my plugin. To do this, I want to pass some arguments to the script. How can I do this? I also want to know how those arguments can be read in script?
Thanks in advance..Here is a simple example of how to run some script code from a plug-in.
InterfacePtr scriptManager(Utils()->QueryScriptManager(kJavaScriptMgrBoss));
if (!scriptManager)
return;
InterfacePtr scriptEngine(scriptManager->QueryDefaultEngine());
if (!scriptEngine)
return;
InterfacePtr scriptRunner(scriptEngine, UseDefaultIID());
if (!scriptRunner)
return;
RunScriptParams params(scriptRunner);
scriptRunner->RunScript("alert('hello from planet script!');", params);
Replace "alert(...);" with your own script. -
How to pass arguments to a Unix shell script from PL/SQL?
We want to run a Linux shell script from PL/SQL (10g). This is our code to run the script only and it works fine.
dbms_scheduler.create_job
job_name=>'RUN_LINUX_SCRIPT_' || v_job_name,
job_type=>'EXECUTABLE',
job_action=>'/vol0/FileLoadDir/Bank/DATA_FILES/spell_check.sh',
enabled=>TRUE,
auto_drop=>FALSE
);Now we have a requirement to pass 2 arguments to the .sh file. In the .sh file the 2 arguments are defined as $1 and $2.
I used this method.
dbms_scheduler.create_job
job_name=>'RUN_LINUX_SCRIPT_' || v_job_name,
job_type=>'EXECUTABLE',
job_action=>'/vol0/FileLoadDir/Bank/DATA_FILES/spell_check2.sh',
--job_action=>'/vol0/FileLoadDir/Bank/DATA_FILES/spell_check2.sh /vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt /vol0/FileLoadDir/Bank/DATA_FILES/abcdefghij.txt',
--job_action=>'#!/bin/bash spell /vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt > /vol0/FileLoadDir/Bank/DATA_FILES/abcde.txt',
number_of_arguments => 2,
enabled=>FALSE,
auto_drop=>FALSE,
comments => 'Testing by Channa'
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
job_name => 'RUN_LINUX_SCRIPT_' || v_job_name,
argument_position => 1,
argument_value => '/vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt');
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
job_name => 'RUN_LINUX_SCRIPT_' || v_job_name,
argument_position => 2,
argument_value => '/vol0/FileLoadDir/Bank/DATA_FILES/abcdefghij.txt');
DBMS_SCHEDULER.enable (name => 'RUN_LINUX_SCRIPT_' || v_job_name);But I get an error saying:
STANDARD_ERROR="/vol0/FileLoadDir/Bank/DATA_FILES/spell_check2.sh: line 4: read: `/vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt': not a valid identifier
/vol0/FileLoadDir/Bank/DATA_FILES/spell_check2"Check this post:
pass parameter from PL/SQL to Unix "as is" -
How to pass arguments into a Captivate project
Hello,
We use dotNetNuke (DNN) as our Content Management System. We are using tokens in DNN to personalize the screens. We have access to the uses first name and email. I would like to pass this information into a Captivate project. I have seen references in my research to using Javascript to invoke the Captivate project, but I have not found any samples of the source code, nor examples of how to use the passed values in the Captivate presentation. Can someone validate that this functionality exists for Captivate 8 and perhaps point me to a few examples?
Thanks,
PeterSorry. I think I was a bit too vague in my answer.
And I don't know about how you are getting your token value, but that part is up to you.
Just make sure to put it in place of where I wrote "whateveryourtokenvalueiscalled".
1.
create a variable in cp to hold your value. (e.g. holdName)
2.
Add this inside the <head></head> tags of your page (after you export it):
<script>
function = getMyValues () {
if(window.cpAPIInterface)
//assign your token value to the cp variable you created in the project
window.cpAPIInterface.setVariableValue("holdName",whateveryourtokenvalueiscalled);
</script>
3.
Back in your cp project, call to the function at some point.
For example, on page 2, add to the page's action
On Enter:
Execute Javascript
Then in the script window, type this to start up the function:
getMyValues();
I hope that makes sense. I'm not really great at explaining scripting unfortunately. -
How to pass arguments from command line to the .jsx
Hi, I have a .jsx file that does some scripting with photoshop. I would like to be able to call that script from the command line and pass some arguments. I have been going off of the forum at http://support.muse.adobe.com/thread/290023, mainly the last post. Here it is ...
command line example : runjavascript.vbs c:\mydirectory\test.jsx arg0 arg1 arg2 arg3
=====start runjavascript.vbs ===============
Set vbsArguments = WScript.Arguments
If vbsArguments.Length = 0 Then
WScript.Echo "Argument(0) is `your script to execute"
WScript.Echo "Arguments(0+n) are passed to your script as argument(0) to argument(n-1)"
Else
ReDim jsxArguments(vbsArguments.length-2)
for i = 1 to vbsArguments.length - 1
jsxArguments(i-1) = vbsArguments(i)
Next
Set photoshop = CreateObject( "Photoshop.Application" )
photoshop.BringToFront
'DoJavaScript has 3 parameters
' syntax DoJavaScript(arg[0], arg[1], arg[2]]
'arg[0] == javascript file to execute, full pathname
'arg[1] == an array of arguments to past to the javascript
'arg[2] == AiJavaScriptExecutionMode: aiNeverShowDebugger = 1,, aiDebuggerOnError = 2 aiBeforeRunning = 3
' only use 1
Call photoshop.DoJavaScriptFile( vbsArguments(0), jsxArguments, 1)
End IF
=====end runjavascript.vbs ===============
=======start test.jsx ====================
#target photoshop
for( n = 0 ; n < arguments.length; n++ ){
alert("argument("+ n+")= " + arguments[n]);
=======end test.jsx ====================
In summary, it calls a VBScript from the command line and passing args to the VBScript where it will run the .jsx and pass along the args to the .jsx. This is all seems to work, except that the args never make it from the command line into the .jsx and I'm having trouble narrowing down why.
I know the args are getting into the VBScript from the command line because I can successfully print them out using WScript.Echo. The VBScript then takes the args and makes a new array called jsxArguments which just holds the arguments that are to be passed on to the .jsx as the second argument in the DoJavaScriptFile().
I cannot tell if the jsxArguments is correct or not. I added an isobject(jsxArguments) check in the VBScript which fails, but if I do a WScript.Echo jsxArguments(0) it will correctly print out the contents of the array at that position.
I know that the args are not getting into the .jsx because I added a line alert(arguments.length) which prints out 0.
Any help would be greatly appreciated. Thanks.I don't use VBS so this is just a guess based on what I have read in this forum. I think when you are passing an 'array' to javascript it needs to be a variant data type. My guess your arguments are not making it to the javascript because it it the wrong data type.
-
Problem in factory method, how to pass arguments ?
Hello it's me again :)
here's the code :
package print;
import java.util.*;
import static print.Print.*;
interface Fact<T> {
T create(String n);;
T create ();
class PetColl {
public String toString() {
return getClass().getSimpleName();
static List<Fact<? extends Pet>> petSpecies=
new ArrayList<Fact<? extends Pet>>();
static {
// Collections.addAll() gives an "unchecked generic
// array creation ... for varargs parameter" warning.
petSpecies.add(new Cymric.Factory());
petSpecies.add(new EgyptianMau.Factory());
petSpecies.add(new Hamster.Factory());
petSpecies.add(new Manx.Factory());
petSpecies.add(new Mouse.Factory());
petSpecies.add(new Pug.Factory());
petSpecies.add(new Mutt.Factory());
petSpecies.add(new Rat.Factory());
private static Random rand = new Random(47);
public static Pet createRandom() {
int n = rand.nextInt(petSpecies.size());
return petSpecies.get(n).create();
public Pet[] createArray(int size) {
Pet[] result = new Pet[size];
for(int i = 0; i < size; i++)
result[i] = createRandom();
return result;
public ArrayList<Pet> arrayList(int size) {
ArrayList<Pet> result = new ArrayList<Pet>();
Collections.addAll(result, createArray(size));
return result;
class Individual implements Comparable<Individual> {
private static long counter = 0;
private final long id = counter++;
private String name;
public Individual(String name) { this.name = name; }
// ?name? is optional:
public Individual() {}
public String toString() {
return getClass().getSimpleName() +
(name == null ? "" : " " + name);
public long id() { return id; }
public boolean equals(Object o) {
return o instanceof Individual &&
id == ((Individual)o).id;
public int hashCode() {
int result = 17;
if(name != null)
result = 37 * result + name.hashCode();
result = 37 * result + (int)id;
return result;
public int compareTo(Individual arg) {
// Compare by class name first:
String first = getClass().getSimpleName();
String argFirst = arg.getClass().getSimpleName();
int firstCompare = first.compareTo(argFirst);
if(firstCompare != 0)
return firstCompare;
//second compare by name
if(name != null && arg.name != null) {
int secondCompare = name.compareTo(arg.name);
if(secondCompare != 0)
return secondCompare;
}//third compare by id
return (arg.id < id ? -1 : (arg.id == id ? 0 : 1));
class Pets {
public static final PetColl creator =
//new LiteralPetCreator();
new PetColl();
public static Pet randomPet() {
return creator.createRandom();
public static Pet[] createArray(int size) {
return creator.createArray(size);
public static ArrayList<Pet> arrayList(int size) {
return creator.arrayList(size);
class Person extends Individual {
String name;
public static class Factory implements Fact<Person>{
public Person create(String name){
Person.name=name;
return new Person(); }
public Person create(){return new Person();}
class Pet extends Individual {
class Dog extends Pet {
class Mutt extends Dog {
public static class Factory implements Fact<Mutt> {
public Mutt create(String name){return new Mutt(name);}
public Mutt create () {return new Mutt();}
class Pug extends Dog {
public static class Factory implements Fact<Pug> {
public Pug create(String name){return new Pug(name);}
public Pug create () {return new Pug();}
class Cat extends Pet {
class EgyptianMau extends Cat {
public static class Factory implements Fact<EgyptianMau> {
public EgyptianMau create(String name){return new EgyptianMau(name);}
public EgyptianMau create () {return new EgyptianMau();}
class Manx extends Cat {
public static class Factory implements Fact<Manx> {
public Manx create(String name){return new Manx(name);}
public Manx create () {return new Manx();}
class Cymric extends Manx {
public static class Factory implements Fact<Cymric> {
public Cymric create(String name){return new Cymric(name);}
public Cymric create () {return new Cymric();}
class Rodent extends Pet {
class Rat extends Rodent {
public static class Factory implements Fact<Rat> {
public Rat create(String name){return new Rat(name);}
public Rat create () {return new Rat();}
class Mouse extends Rodent {
public static class Factory implements Fact<Mouse> {
public Mouse create(String name){return new Mouse(name);}
public Mouse create () {return new Mouse();}
class Hamster extends Rodent {
public static class Factory implements Fact<Hamster> {
public Hamster create(String name){return new Hamster(name);}
public Hamster create () {return new Hamster();}
public class Test {
public static void main(String[] args) {
for(Pet p:Pets.creator.arrayList(25)){
PetCount.petC.count(p.getClass().getSimpleName());
print(p.getClass().getSimpleName());}
class PetCount {
static class PetCounter extends HashMap<String,Integer> {
public void count(String type) {
Integer quantity = get(type);
if(quantity == null)
put(type, 1);
else
put(type, quantity + 1);
public static PetCounter petC= new PetCounter();
}and here's my problem:
I'm trying to fill up list using factory method but in a fact that I want to have two constructors, I have a problem to set field name of objects of those classes. Is there any possibility to use in that way some factory method to create that list ?
In Person class I've tried to set it in factory method before creating an object, but as you know that option is only alvailable for static fields which i don't want to be static.I for one have no idea what you're asking, and what you seem to be saying doesn't make sense.
I'm trying to fill up list using factory method but in a fact that I want to have two constructors,Two constructors for what? The factory class? The classes that the factory instantiates?
I have a problem
to set field name of objects of those classes. Is there any possibility to use in that way some factory method to
create that list ?What?
In Person class I've tried to set it in factory method before creating an object, but as you know that option is only alvailable for static fields which i don't want to be static.That doesn't make any sense. A Factory can easily set fields in the objects it creates on the fly (not static).
Maybe you are looking for
-
I don't know if its just me being majorly dense but I am unable to get airplay to work. I have an iPad mini which I want to mirror on my mac mini which I have Airserver installed on. I have the mac mini hardwired but also I have it connected to the s
-
Thin white border around image in browser
In Firefox and Safari a thin white border appears around a black image. My background is black so.....is it a matter of the blacks being slightly different? I'd like the image to appear seamless on the page. How can I fix this? http://wall-eye.com/ab
-
SAP Output as MS word doc.
My requirement is to get the output as a MS word format .. without using any third party toool? Can we really achieve it or not ? What we propsed is a solution is to get the output to a PDF file then to use the PDF to word converter which cost them
-
Hi, Can neone pls tell me whats the meaning of this and how to accomplish.. "Email Receiver QPAC test tab:known issues You must add the javamail jar files to the PAD classpath in order for the test tab on the Email Receiver QPAC to function correctly
-
How to select non-contiguous text
In the previous version of pages, you could select non-contigous text. In the new versioin, you cannot. WHY???