how to identify java class path and name to trouble shoot java - java

I'm using a java bootstrapping command to update a web application according to an xml file I've configured. The xml file has been checked and it's formatted correctly and referenced correctly in the script.
The problem: I keep getting an error that the system could not find or load the main class.
What I would like to do is to view the contents of the jar file. I know that to do this, I should run:
jar tf jarfilenameandpath
What I don't know is WHERE I should run the command. I tried it from a windows command prompt and received the following error:
'jar' is not recognized as an internal or external command, operable file, or batch file.

You don't have to run that command to see whats there in .jar better
way to do it is download the Java Decompiler
See all the classes and try to find the conflict. If everythings looks fine. The only way you can solve this problem is by debugging it.
Did you set Java PATH variable on your Windows machine?
For more details on de-compilers, visit this page on stackoverflow

Related

Zookeeper cli not starting

I've installed zookeeper v 3.4.9 on suse using the following package:
http://download.opensuse.org/repositories/home:/nicolasbock:/midokura/openSUSE_Leap_42.2/x86_64/zookeeper-3.4.9-1.1.x86_64.rpm
Starting the server works just fine an the various application that need to connect to it seem to be able to do so just fine, however I'm getting a strange error when I try to start the client:
zkCli.sh -server 127.0.0.1:2181
Error: Could not find or load main class org.apache.zookeeper.ZooKeeperMain
I've tried searching around the internet but the only answer I've come up with is setting the env variable $CLASSPATH. I tried looking what classpath is used internally by the serve starting script and set $CLASSPATH to that but with no results.
I'm running openjvm v 1.8.0_121
I encountered this problem today on Ubuntu 18.04. On zookeper official download page once one follows the given mirror link and chooses stable version, he can see 2 files available. In my case those were:
apache-zookeeper-3.5.5-bin.tar.gz
apache-zookeeper-3.5.5.tar.gz
I chose apache-zookeeper-3.5.5.tar.gz, observed the same problem. Tried to print CLASSPATH as #Jonathan suggested, it was printing different paths however, problem is that the archive file did not contain zookeper jars, probably it is expected that user packages to jar himself as I could find source code in that archive file.
Downloading larger apache-zookeeper-3.5.5-bin.tar.gz archive, extracting and running ./zkCli.sh went smooth as it had everything necessary, so whoever faces the same problem, try that and see if it does the trick for you.
Are you trying on Unix or Windows?
I dont think, you need "-server 127.0.0.1:2181"
Just run zkCli.sh or zkCli.cmd
That is a classpath problem. The zkCli.sh script is attempting to launch a java app where the main class is ZooKeeperMain. However, java cannot find the ZooKeeperMain class file because the classpath being passed to java does not contain a jar file that contains the ZooKeeperMain class.
Typically, the ZooKeeperMain.class file is contained in a jar file at something like $ZOOKEEPER_HOME/zookeeper-3.4.13.jar.
You might trying modifying the zkCli.sh script to print out the classpath just before the script attempts to launch ZooKeeperMain. The classpath should contain the jar that contains the ZooKeeperMain class.
On my Windows 10 machine, my classpath looks like this:
/c/Program Files (x86)/Zookeeper/bin/../build/classes:/c/Program Files (x86)/Zookeeper/bin/../lib/slf4j-log4j12-1.7.25.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/slf4j-api-1.7.25.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/netty-3.10.6.Final.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/log4j-1.2.17.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/jline-0.9.94.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/audience-annotations-0.5.0.jar:/c/Program Files (x86)/Zookeeper/bin/../zookeeper-3.4.12.jar:/c/Program Files (x86)/Zookeeper/bin/../conf:
I encountered a similar errors as yours when launching zkCli.sh from Git Bash for Windows on my Windows 10 machine. My issue was because of the way Git Bash was handling wildcards in the classpath. I initially had some *.jar entries in my classpath that I removed to get zkCli.sh to launch.

The system cannot find the file C:\play\bin\..\conf\sbtconfig.txt

ACTIVATOR_HOME=C:\play
The system cannot find the file `C:\play\bin\..\conf\sbtconfig.txt.
'findstr' is not recognized as an internal or external command, operable program or batch file.
The syntax of the command is incorrect.
I'm facing this problem while installing the play framework.
I intalled sbt and Scala as referenced by one tutorial on the internet, but in vain.
My Java JDK is working properly and sbtconfig.txt file is not in play bin where above file is point to.
Please can anyone help me?
If you do not provide sbtconfig.txt then installer will throw warning but it will not stop. I have successfully installed play2 even after that message.
So please check that SBT_HOME and ACTIVATOR_HOME are correctly configured. But you got some other error like 'findstr' not found. So try both from creating a command shell and also by double clicking the batch file. I hope that can solve the problem.

MaltParser cannot find configuration file if it is not in current directory

I have trained a model using maltparser version 1.8.1, and I can parse text just fine, but I tried to do it from a non-local directory,
java -Xmx6G -jar /Users/me/maltparser-1.8.1/maltparser-1.8.1.jar -c /Users/me/maltparser-1.8.1/configFile -m parse
and I get the following error:
Couldn't find the MaltParser configuration file: /Users/me/maltparser-1.8.1/configFile.mco
However, the file definitely exists. I copied the text from the error:
$ ls /Users/me/maltparser-1.8.1/configFile.mco
/Users/me/maltparser-1.8.1/configFile.mco
The only way that I can get it to work is if I run java in the directory where the configuration file is. Is there something special that I have to do to use a full path for the configuration file?
It would be possible, I suppose, to cd in a shell script to make this work, but I still want to understand why doing it this way doesn't work.
I was facing the same problem, but then I looked into the source code and found out that you need to provide the relative path of the configuration file from the place you are executing the java command. This is because the path where you have executed the program is prepended to the path of the config file you provide as argument, unless you have mentioned the working directory as argument(in this case put the config in the working directory).

How to include sqlite db file into jar in netbeans?

I use sqlite in my java application. When I run it from Netbeans, it works well. The sqlite db file is located in the root project directory (same level as build.xml).
This is the code to access the database file:
DriverManager.getConnection("jdbc:sqlite:database.db");
However, when I build the project, and run the jar file outside netbeans, I always get this error: no such table: table_name
My question: where is the correct location to put the "sqlite db" file? Is it possible to package it inside the JAR file?
I have tried to package my application into a single JAR file (similar to Eclipse's FatJar), but I still get that error. In this case I modify the build.xml as explained in this blog:
Netbeans single JAR
I also tried to create a database folder in the src directory and then put the db file inside the folder (src/database/database.db) and access it using
DriverManager.getConnection("jdbc:sqlite:src/database/database.db");
I can run it inside netbeans. But when I run it outside, I got this error:
path to 'src/database/database.db':C:\Windows\system32\src' does not exist
I know there are similar questions to this in stackoverflow, but most of them don't have a concrete solution. Let me know if someone has found a better one.
Thanks a lot.
Problem solved!
I made a mistake in the way I execute the JAR file. Previously I run the JAR file by right click on it and open it with Java SE binary. I need to do this because in my PC the default program to open JAR file was set to another software.
It turned out that I have to set the default program to Java SE Binary and the double click the JAR file in order to run my application. Using this way I can run and access the sqlite db file without a problem.
I hope this can help others who may get the same problem as I had.
probably you need to point your app to include your app base directory in the classpath.
the command to run your app should be something like:
java -cp . YourAppMainClass
the "-cp . " is the command option that tells java to include current directory in the classpath.

How to fix internal or external command errors in Netbeans?

It builds fine, but when netbeans tries to start the emulator, the following error occurs:
'Blackberry' is not recognized as an internal or external command, operable
program or batch file.
I'm searching for a general solution. Because I found many of the same type of errors on the net (But each one without an answer).
'xxx' is not recognized as an internal or external command, operable
program or batch file.
So how do you make Netbeans recognize 'xxx'?
add the path to your executable to your system path variable .
it will look at those path while executing any executable if executable found from any of those path it OR from current dir it will execute otherwise it will throw the same error.
For Linux you have
PATH=$PATH:/home/user/path/to/executable
for windows you will have something like ,edit it. follow this tutorial for more info

Categories