I have a stand alone project in my eclipse.There are few external jar as well.The programme is executing well and giving required result. Now i need it to run from command prompt.and i just want to run the class file generated by eclipse. how i will be able to run it.When i am tring to run it from commend prompt it is giving class not found exception.I also tried to make an executable jar,but that is also not running.do i need to create executable jar or i can simply run it from command prompt..tell me the way out..
thanks
koushik
A step by step guide at
I recommend you to go through jar, class path and other basic building blocks of java for eg check this about jar
try using this command java -cp . package.name.className
Related
https://kafka.apache.org/10/documentation/streams/quickstart
I'm trying to run my own application (on Linux) using Kafka Streams. I was able to successfully follow the instructions on their page and run the WordCountDemo application. Now I'm trying to use my own app (right now it is the same code, but I plan on doing something else with it) and when I write the command bin/kafka-run-class.sh com.zzz.WordCount I get Error: Could not find or load main class com.zzz.WordCount
I have my own WordCount.java like the following
/opt/kafka_2.12-1.0.0/src/main/com/zzz/WordCount.java
Is there anything else I need to do with my own app in order to be able to run it with kafka streams on my machine? Thanks.
You need to make sure that bin/kafka-run-class.sh finds your own class in the Java classpath.
Before you run bin/kafka-run-class.sh execute
export CLASSPATH="$CLASSPATH":"/opt/kafka_2.12-1.0.0/src/main/"
This should allow bin/kafka-run-class.sh to pick it up correctly.
I created the maven project containing the WordCountDemo.java program on my local machine. Executed the following steps
Export the project as a jar file - e.g. WordCount.jar.
Put the jar file on some server with the kafka setup.
Specify that jar file in the classpath.
export CLASSPATH="$CLASSPATH":"/my/sever/dir/WordCount.jar"
Then the following command was executed without any problem.
bin/kafka-run-class.sh com.zzz.WordCountDemo
I have seen many people ask this question but none of the answers have solved my problem.
I have written a Java project in Intellij which runs fine in Intellij. I need it to run on the command line however.
Intellij automatically builds the .class files in the following directories which is outlined as follows:
C:\git\myProject\out\production\myProject\main
C:\git\myProject\out\production\myProject\openNlpTools
C:\git\myProject\out\production\myProject\sentimentAnalysisTools
I have three sub directories here. The file with the main method is in the \main folder.
To run the program I thought I used the following:
java main.FileMonitor
When I run this however I get the following error:
Error: Could not find or load main class main.FileMonitor
Does anyone have any tips as to why this isn't running?
Intellij runs the program fine, is there anyway I can see the command IntelliJ uses to run the program?
Thanks!
If you can't file a class it usually means you didn't include it in your class path. Some ways to run in the command line
Copy from IntelliJ
Run the program in InetlliJ.
Copy the first line as this will contain full command line
Edit the command line to remove bits you don't need.
Using Maven/Gradle
Set the Main-Class in the assembly plugin
build the program with assembly:single
this will create a Jar you can run on the command line.
I wrote an application which starts by reading a configuration (.ini) file and accordingly parses some xml files within a particular folder.
Everything works perfectly when I build and run my application in NetBeans. Now I wanted to run my application through command line (because that's actual requirement of my project), so I am executing the .jar file created by Netbeans to run my application.
I am executing the application as such: java -jar Application.jar.
The issue is when I run this command on command line, the application seems to not be able to find the configuration file which is in the root folder of the project. Its really odd because NetBeans runs it perfectly.
I believe the reason I am getting this exception is because to run the .jar file I am changing my directory to dist and then running the java -jar command and therefore the file is not being found . But then how do I get around this.
Any help is appreciated. Thank you
Sorry got it figured out. I am executing jar file from the root but adding the source in the command as well.
Sorry, you can close this thread.
I had this problem till I installed JRE and did NOT use stand alone.
I have just completed my first Java Program, it works inside netbeans...but when I clean and build and run the executable jar file, it opens the GUI but none of the database functions work. I tried using JSmooth but I was either doing something wrong or it was not working on my computer. Im assuming that when i run the program outside of netbeans it cannot find the JDBC jar? how can i fix this?
Yes, most probably you are getting a ClassNotFoundException in the background. If you are starting your application from command line, you can specify jars to be on the classpath as follows:
java -cp jdbcdriver.jar my.package.MainClass
I'm using Windows Server 2003,and I'm building a webpage and I want a particular testcase(a Java code) to execute when I click a button in that webpage(the webpage is in same server). SO first I have to find a way to run this eclipse java codes in command line.
On doing some research I found I need to install Maven or Ant. But I know this is not really required. I'm not sure which way to go. I prefer not using Maven or Ant. Can someone please tell me the steps to execute These tests in Command line. ALso the environment variables to add Because I'm unable to find QTjava.zip file in jre7 /lib/ext/ folder.
Have a look at the javac and java command line options. Heres what I did to run selenium tests without requiring eclipse or maven/ant.
this compiles your class, with the jar file (i put it in the same directory, but ideally you will put the full path in the qoutemarks:
javac -classpath "selenium-server-standalone-2.33.0.jar" Example.java
Then you can run the generated class via:
java -classpath ".;selenium-server-standalone-2.33.0.jar" Example
Hope that helps.