Not able to print GC details - java

I am trying to print the GC details for a test program in eclipse.I want to set it only for my program so I went to Run>Run Configurations and in VM arguments gave this:
-Xms1024M -Xmx1024M –XX:+PrintGCDetails –XX:+PrintGCTimeStamps
However when I do this and run my program I get the following error:
java.lang.NoClassDefFoundError: –XX:+PrintGCDetails
Caused by: java.lang.ClassNotFoundException: –XX:+PrintGCDetails
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
What am I doing wrong in passing the arguments.

What should tip you off is the error message NoClassDefFoundError: –XX:+PrintGCDetails - the JVM isn't trying to parse it as an option but a class...
Then, look at the dashes before -Xms1024M and –XX:+PrintGCDetails / –XX:+PrintGCTimeStamps - they're different!
Replace the latter ones with the former (ie. "real" dashes/minus-sign) and you're good to go.
Cheers,

Related

Jdbc no suitable driver found. Postgresql [duplicate]

Note
I'm running windows, the path just looks like it's linus because I typed it manually and thats how I think of paths.
I'm trying to run a java class That I have built to diagnose my connection to a databse, it references the oracle jdbc adaptor.
When I just run it without a class path:
%> java DBDiagnostics <connectionString>
I get an exception when it reaches the following line of code:
Class.forName("oracle.jdbc.pool.OracleDataSource").newInstance();
with the following exception:
java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleDataSource
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at DBDiagnostics.GetConnection(DBDiagnostics.java:43)
at DBDiagnostics.runDiagnostic(DBDiagnostics.java:29)
at DBDiagnostics.main(DBDiagnostics.java:18)
Creating connection.
java.sql.SQLException: No suitable driver found for lskd
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at DBDiagnostics.GetConnection(DBDiagnostics.java:55)
at DBDiagnostics.runDiagnostic(DBDiagnostics.java:29)
at DBDiagnostics.main(DBDiagnostics.java:18)
Veryfying connectivity to Database
Exception in thread "main" java.lang.NullPointerException
at DBDiagnostics.verifyTable(DBDiagnostics.java:86)
at DBDiagnostics.verifyTable(DBDiagnostics.java:76)
at DBDiagnostics.verifyDatabseConnectivity(DBDiagnostics.java:68)
at DBDiagnostics.runDiagnostic(DBDiagnostics.java:36)
at DBDiagnostics.main(DBDiagnostics.java:18)
I assume that this is because I need to include it in the classpath.
So, I tried adding it to the classpath like this:
%> java -classpath .:ojdbc6.jar DBDiagnostics <connectionString>
The VM just says it cant find the class:
Exception in thread "main" java.lang.NoClassDefFoundError: DBDiagnostics
Caused by: java.lang.ClassNotFoundException: DBDiagnostics
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: DBDiagnostics. Program will exit.
I know this is a question I should just know the answer to, but what am I doing wrong?
Replace the colon with a semicolon:
java -classpath .;ojdbc6.jar DBDiagnostics <connectionString>
is there a typo:
%> java -classpath .:ojdbc6.jar DBDiagnostics <connectionString>
maybe it would work if you type this:
%> java -classpath ./ojdbc6.jar DBDiagnostics <connectionString>
Does the DBDiagnostics.class file appear in the directory from which you're launching Java? If not, the class loader won't find it.
Does the DBDiagnostics class have a package? If it does, you have to refer to the fully resolved class name, and the root of the package hierarchy has to appear in the directory from which you launch Java.
Mike Sickler's answer looks right for a Windows platform. The path separator for Windows is ";", but ":" for Unix and Linux, so make sure you always use the right one!
Long shot, but is this Unix or Windows? If on Windows the class path separator should be a semi colon:-
%> java -classpath .;ojdbc6.jar DBDiagnostics <connectionString>
And of course you need to have the ojdbc6.jar file in the current directory if you don't specify any path to it. (And possibly it's dependencies as well...)

How to use java heap profilers (HPROF)

With the basic knowledge of java 'hprof', I tried executing the below command as per oracle docs
java -agentlib:hprof Hello.class
But i get the below error instead of the profiling information
Caused by: java.lang.ClassNotFoundException: Hello.class
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Can someone illustrate on how should hprof be used properly so as to get the profiling information ?
You just need to remove the .class at the end of the class as Java by default will search for class files.
java -agentlib:hprof Hello
However, to get the heap allocation profile you need to add some parameters...
java -agentlib:hprof=heap=sites Hello
For more information type
java -agentlib:hprof=help
And visit http://docs.oracle.com/javase/8/docs/technotes/samples/hprof.html

Java - NoClassDefFoundError on starting up local version of DynamoDB

I'm trying to start local version of DynamoDB on the command line (OSX) using the following command as specified in the documentation:
java –Djava.library.path=. -jar DynamoDBLocal.jar
But getting the following errors:
Exception in thread "main" java.lang.NoClassDefFoundError: �Djava/library/path=/
Caused by: java.lang.ClassNotFoundException: �Djava.library.path=.
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Any ideas on how to resolve this issue?
The � shows that it may be a character, which looks like hyphen '-' . Please inspect this.
Also, whenever you are using -D option, its best practice to use a complete jar name (rather than wild card). This will make sure that you are missing nothing.

running python using jython

I want to run a python function using jython..
Taking the example from this site.
http://sundaycomputing.blogspot.com/2011/01/python-udfs-from-pig-scripts.html
Now when i run the script (pig -f myscript.pig
It returns me this error
Pig Stack Trace
---------------
ERROR 2998: Unhandled internal error. org/python/core/PyException
java.lang.NoClassDefFoundError: org/python/core/PyException
at org.apache.pig.scripting.jython.JythonScriptEngine.registerFunctions(JythonScriptEngine.java:127)
at org.apache.pig.PigServer.registerCode(PigServer.java:567)
at org.apache.pig.tools.grunt.GruntParser.processRegister(GruntParser.java:421)
at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:419)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:188)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:164)
at org.apache.pig.tools.grunt.Grunt.exec(Grunt.java:81)
at org.apache.pig.Main.run(Main.java:427)
at org.apache.pig.Main.main(Main.java:108)
Caused by: java.lang.ClassNotFoundException: org.python.core.PyException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 9 more
================================================================================
I am guessing its because of the first line.. REGISTER udf.py USING jython AS udf;
and that I have to specify jython path? (since i am running this code on cluster.. i dont think i have set this thing up)..
Now... since i dont know much of java.. hence switched on python ... but how do i make this code run??
What sort of setup i have to do on my env... to debug this problem.
Thanks
Add $PIG_HOME/lib/jython.jar to your PIG_CLASSPATH environment variable.

Unable to run a Java Program with the command line option -DsocksProxyHost

When I run a Java program with a command line option -DsocksProxyHost 10.123.76.20, I got an error :
java.lang.NoClassDefFoundError: 10/123/76/20
Caused by: java.lang.ClassNotFoundException: 10.123.76.20
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: 10.123.76.20. Program will exit.
Exception in thread "main"
-D should be used as follows:
-DsocksProxyHost=10.123.76.20
It would be helpful if you put on your command line here.
To run a Java program from command line, you have to specify the class which you would like to be invoked.
Let's say your program is located in c:\program\my.jar and com.myapp is the full name of the class you want to run, you should do like this:
java -cp c:\program\my.jar com.myapp -DsocksProxyHost 10.123.76.20

Categories

Resources