Batch to call Java main class - java

I am getting an error for below batch file.
cls
set classpath=C:\Program^ Files\salesforce.com\Data^ Loader\dataloader-29.0.0-uber.jar
set mainclass=com.salesforce.dataloader.process.ProcessRunner
set confdir=C:\Program^ Files\salesforce.com\Data^ Loader\Bkp\
if [%1]==[] goto error
call java -cp %classpath% -Dsalesforce.config.dir=%confdir% %mainclass% process.name=Product_vod__c sfdc.extractionSOQL="SELECT
Id,name FROM Product_vod__c where Id in %1"
goto end
:error
echo Error: missing date argument (must be in 'yyyy-mm-ddThh:mm:ssZ' format)
:end
Error
Could not find or load main class Files\salesforce.com\Data
Can someone please let me know the issue?
Thanks

You've got an unescaped Program Files somewhere in your classpath and its space breaks the classpath argument : the classpath stops at Program and java parses the following Files\salesforce.com\Data as the class it should execute.
You should enclose classpath fragments containing spaces with double-quotes.

Related

Can we delete records from Meta Dictionary

I am trying to re-compile one of the .Java file in Oracle 11g and I am getting the below error:
$ . /dboracle/orabase/product/11.2.0.BTSP8/bin/loadjava -verbose -resolve -synonym -user nm/nm -grant PUBLIC DeviceAttribParserConstants.java
arguments: '-user' 'nm/***' '-verbose' '-resolve' '-synonym' '-grant' 'PUBLIC' ' DeviceAttribParserConstants.java'
creating : source com/bt/nmsloader/model/DeviceAttribParserConstants
loading : source com/bt/nmsloader/model/DeviceAttribParserConstants
Error while creating source com/bt/nmsloader/model/DeviceAttribParserConstants
ORA-29542: class com/bt/nmsloader/model/DeviceAttribParserConstants already defined by source DeviceAttribParserConstants/java
ORA-06512: at line 1
The following operations failed
source com/bt/nmsloader/model/DeviceAttribParserConstants: creation (createFailed)
exiting : Failures occurred during processing
When I have looked in the ALL_Objects meta-dictionary I did not found JAVA SOURCE but can only see JAVA CLASS for DeviceAttribParserConstants.
Now when I am trying to recompile then I am getting above error and if I am dropping the same JAVA class file then I am getting error as below:
ORA-29537: class or resource cannot be created or dropped directly.
ORA-06512: at line1
* Cause: An attempt was made to create or drop JAVA class or resources that is a known result from compilation of an existing JAVA Source object.
I am stuck. Can someone help me in resolving this error.
Many thanks in advance.
Regards,
Himmy Chauhan
Can we delete records from Meta Dictionary
You shouldn't as it is likely to corrupt your database.
Now when I am trying to recompile then I am getting above error and if I am dropping the same JAVA class file then I am getting error as below:
ORA-29537: class or resource cannot be created or dropped directly.
ORA-06512: at line1
* Cause: An attempt was made to create or drop JAVA class or resources that is a known result from compilation of an existing JAVA Source object.
The loadjava utility has a force option:
-force Forces files to be loaded, even if they match digest table entries.
So you can try:
loadjava -verbose -force -resolve -synonym -user nm/nm -grant PUBLIC DeviceAttribParserConstants.java
You can also try to drop the existing java object:
SELECT OWNER, OBJECT_NAME
FROM ALL_OBJECTS
WHERE OWNER = 'NM'
AND OBJECT_NAME LIKE '%DeviceAttribParserConstants';
DROP JAVA CLASS NM.<insert_object_name>
and then try using loadjava without the force option.
(You may want to try backing up the existing class file before you drop/overwrite it just in case you need to revert to the prior version.)

BeanShell command line interpreter features

I'm trying to test BeanShell's command line interpreter in how it processes basic Java commands and syntax on my machine, and see if I can customise its behavior in any way. I've installed version 2.0b4 on my machine running OS X 10.10.1 (the JAR file is in /Library/Java/Extensions as per the instructions).
It's the closest thing to what I've been looking for, an interactive Java interpreter, but it doesn't have some standard features which a good interpreter should have.
I'd like to be able to use the Up arrow key to reuse a previous command, but at the moment it doesn't recognise it, it just shows a control sequence. Is there a way to customise this for BeanShell?
Is there a way to get BeanShell to print out the value of a variable if I've created it beforehand, just by naming it, like
String s = new String( "Hello World!" );
s;
Hello World!.
This is possible in Python for example.
According to the documentation on importing Java classes which(<java class>); should return the classpath location of the specified Java class. But which( java.lang.String ); does not work for me, I get a NullPointerException:
bsh % which(java.lang.String);
Start ClassPath Mapping
Mapping: Directory /Users/srm
// Error: // Uncaught Exception: Method Invocation cp.getClassSource : at Line: 42 : in file: /bsh/commands/which.bsh : cp .getClassSource ( className )
Called from method: which : at Line: 8 : in file: : which ( java .lang .String )
Target exception: java.lang.NullPointerException
java.lang.NullPointerException
Any pointers or help would be appreciated.
Run beanshell with jline.
Download jline jar from http://jline.sourceforge.net/index.html and then you can do:
java -cp jline-1.0.jar:bsh-2.0b4.jar jline.ConsoleRunner bsh.Interpreter
Line editing capability will be provided by jline. I found this hint here.
There are issues running with jline2. First, you'll get:
$ java -cp jline-2.12.jar:bsh-2.0b4.jar jline.ConsoleRunner bsh.Interpreter
Exception in thread "main" java.lang.NoClassDefFoundError: jline/ConsoleRunner
Due to this issue which is fixed. But then, use the new class and you still get:
$ java -cp jline-2.12.jar:bsh-2.0b4.jar jline.console.internal.ConsoleRunner bsh.Interpreter
Exception in thread "main" java.lang.IllegalArgumentException: wrong number of arguments
due to this issue which is not fixed yet.
Use show() command which will trigger showing of value.
bsh % show();
bsh % String s = new String("Hello World");
bsh % s;
<Hello World>
bsh %
It is mentioned in the Useful BeanShell Commands section of the documentation.
Doesn't work for me either
It doesn't fail in my case, but it didn't find it either.
bsh % which(java.lang.String);
Start ClassPath Mapping
Mapping: Archive: file:/Users/me/beanshell/jline-1.0.jar
Mapping: Archive: file:/Users/me/beanshell/bsh-2.0b4.jar
Mapping: Archive: file:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar
End ClassPath Mapping
null
bsh %

Setting up jdk for ruboto - error

I'm following this tutorial here for setting up Ruboto: http://rubylearning.com/blog/ruboto-quick-start/
I got an error setting up system environment variables in my command line in the JDK step. This is the code I typed in and error received:
$ path=%path%;c:"Program Files"\Java\jdk1.7.0_45\bin;
> classpath=%classpath%;.;
> JAVA_HOME=c:\"Program Files"\Java\jdk1.7.0_45
sh.exe": c:"Program: command not found
Any ideas on what is wrong?
You should surround the whole long pathes with quotes, e. g. :
path=%path%;"c:Program Files\Java\jdk1.7.0_45\bin"
Hope it helps.

Compiling servlet giving error message

I ran the following command to compile a servlet called BeerSelect.java from HeadFirst Servlets and JSP book.
D:\Apache Tomcat\apache-tomcat-5.5.36\apache-tomcat-5.5.36\webapps\Coffee>javac
-classpath /common/lib servlet-api.jar:classes: -d classes src/com/example/web/B
eerSelect.java
My servlet-api.jar is located in D:\Apache Tomcat\apache-tomcat-5.5.36\apache-tomcat-5.5.36\common\lib
MESSAGE
javac: invalid flag: servlet-api.jar:classes:
Usage: javac <options> <source files> use -help for a list of possible options
Cannot understand how to fix this command and compile the servlet. Doing it for the first time new to servlets.
Then I changed the command to be
D:\Apache Tomcat\apache-tomcat-5.5.36\apache-tomcat-5.5.36\webapps\Coffee\WEB-IN
F\src\com\example\web>javac -classpath "D:\Apache Tomcat\apache-tomcat-5.5.36\ap
ache-tomcat-5.5.36\common\lib\servlet-api.jar";classes BeerSelect.java
MESSAGE
BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
BeerSelect.java:32: cannot find symbol
symbol : variable out
location: class com.example.web.BeerSelect
out.println("<br>try: " + it.next());
^
4 errors
Why cannot it find the com.example.model package ?
IMAGE
It looks like you have three issues with your command: extra spaces, Unix-style pathnames, and missing additional Java source files. Try the following instead:
javac -classpath "D:\Apache Tomcat\apache-tomcat-5.5.36\apache-tomcat-5.5.36\common\lib\servlet-api.jar";classes -d classes src\com\example\web\*.java src\com\example\model\*.java
I've removed extra spaces, converted Unix paths to Windows paths, changed the classpath separator from the Unix-style ':' to Windows-style ';', and added your other Java sources - compiling them all together should resolve your first three compiler errors.
As for the last compiler error, that appears to be a genuine source code error - try prepending System. to the out.println("<br>try: " + it.next()); line. (It can also be resolved by a static import, but that would be unconventional.)
D:\Apache Tomcat\apache-tomcat-5.5.36\apache-tomcat-5.5.36\webapps\Coffee>javac -classpath "D:\Apache Tomcat\apache-tomcat-5.5.36\apache-tomcat-5.5.36\common\lib\servlet-api.jar";"D:\Apache Tomcat\apache-tomcat-5.5.36\apache-tomcat-5.5.36\webapps\Coffee\WEB-INF\src" WEB-INF\src\com\example\web\BeerSelect.java
This command works and compiles the class BeerSelect.java.

Unsupport characters in command line file path

I would linke to call java app from PHP:
exec('LC_ALL=en_US.utf-8 java -jar /test.jar' . $filepath . ');
But always there are unsupported characters in the file path.
For example: # & ; ? * [SPACE]..., after change them to # \& ... it will be ok.
But a full list of these characters could not be find.
Any ideas to solve this problem?
Take a look at escapeshellarg() and escapeshellcmd().
They will take care of all necessary sanitation for you.
If $filepath comes from the outside (e.g. from user input), running escapeshellarg() is mandatory to prevent injections.
My problem resolved.
Useful url:
http://bugs.php.net/bug.php?id=44945

Categories

Resources