I'm trying to run my application through intellji so I can debug.
When I run this command from the terminal it works:
java -cp /Users/craigharley/code/IdeaProjects/decaf-CraigHarley/Skeleton/lib/antlr-4.6-complete.jar:Compiler.jar decaf.Main -target inter /Users/craigharley/code/IdeaProjects/decaf-CraigHarley/Skeleton/testdata/semantics/illegal-cust.dcf
But when I create a build using:
Edit Build Configs
New Application
Select the main class
Enter -cp /Users/craigharley/code/IdeaProjects/decaf-CraigHarley/Skeleton/lib/antlr-4.6-complete.jar:Compiler.jar decaf.Main -target inter /Users/craigharley/code/IdeaProjects/decaf-CraigHarley/Skeleton/testdata/semantics/illegal-cust.dcf as the program arguments I get a file not found on the /Users/craigharley/code/IdeaProjects/decaf-CraigHarley/Skeleton/lib/antlr-4.6-complete.jar:Compiler.jar, anyone know why this is?
I assume it's because of the :Compiler.jar, I don't java much so could somebody explain this to me.
Thanks
Related
I can't run the CloudSimSDN via cmd (Command Prompt) and I can't run that via eclipse, too.
I installed eclipse 4.6.0, JDK 1.8.0. The cloudSimSDN needs CloudSim-3.0.3, apache Commons Math, json-simple-1.1.1 and guava-17.0.
I have given below the errors. Could you tell me know what needs to be done?
When I try to execute the example using the following command:
java -cp ./*:. org/cloudbus/cloudsim/sdn/example/SDNExample MFF dataset-energy/energy-physical.json dataset-energy/energy-virtual.json dataset-energy/energy-workload.csv > results.out
java -cp ./*:.This code needs to be write in special directory? Or -cp ./*:. is a special switch in java?(please explain about it. I am beginner in cloudsim, Help me please.
Below are the error codes:
Could not find or load main class org.cloudbus.cloudsim.sdn.example.SDNExample.
My reference of source code: CloudSimSDN
please go through steps mentioned here at tantrabhavan.blogspot.com. It worked for me!!!!
I am using the code from this tutorial to test the JDBC connection. I changed the name of the class to TestJDBC and I altered the database name and query, but otherwise it is identical. When I run the class as a Java application from within eclipse on my devbox, the program runs properly. However, when I copy the file to /home/username/ on a remote CentOS 7 server, typing java TestJDBC.java into the terminal produces the following error:
Error: Could not find or load main class TestJDBC.java
I also the same error when I try java TestJDBC and when I upload the .class file in addition to just the .java file. What else do I need to do in order to call the Java class from the CentOS 7 terminal?
Note that javac TestJDBC.java results in -bash: javac: command not found. And I did try java somepackage.TestJDBC with same results of Error: Could not find or load main class TestJDBC.java as above.
ANSWER NOTE: The answer required getting the development version of openJDK using yum. The PATH variable was not part of the solution. However, I am marking the answer below as accepted because the user who submitted it contributed substantially to the solution.
You should be able to run it after compiling it
javac TestJDBC.java
java TestJDBC
Note that you do not need to add .class when running it from the commandline.
If this still does not work, please paste your code.
EDIT after request
So you've now stated that you're missing javac from your PATH. I'll show you how to add it:
$> export JAVA_HOME=/path/to/jdk/jdk.1.8.0_20
$> export PATH=$PATH:$JAVA_HOME/bin
Verify by running
javac -version
It should print something like
javac 1.8.0_20
I've written a java program and I'm trying to run it from cmd both in Windows and Linux.
I first compiled and then run it , and it worked just fine on Windows.
The problem comes up when I'm trying to do the same thing on Linux. The commands I've used on Linux are :
javac -cp aspose-cells.jar:aspose-words.jar:aspose-slides.jar ConvertToPdf.java
java -cp aspose-cells.jar:aspose-words.jar:aspose-slides.jar ConvertToPdf
The first command , which starts with javac, works just fine and outputs the ConvertToPdf.class file. The problem comes up after running the second one , which outputs the following error:
Error: Could not find or load main class ConvertToPdf
I'd like to know what am I doing wrong , and I'd be grateful if anyone could point me to the solution.
Thanks in advance.
Add the current directory . to the classpath:
java -cp aspose-cells.jar:aspose-words.jar:aspose-slides.jar:. ConvertToPdf
your working directory is not included in class path.
do this :
export CLASSPATH=$CLASSPATH:<your-jars>:.
it should work !!!
Hi I want to run a code on a remote server where IntelliJ Idea is not installed. My code needs a lot of classpath parameter which I handle that with IntelliJ Idea in my local computer. Now how can I export all running parameter and actually a something like:
$ java -cp ... Main.class ...
from Intellij Idea to use on remote server?
thanks.
My code works fine in Eclipse, no build path errors or anything, however when I try to run my Java program from the command line, I get a classNotFound Exception on one of my inner classes. Not only do I not understand how I am getting this exception, but I am not even sure how to go about debugging it, since it looks and works fine in the IDE environment. Any help is appreciated!
Edit
I am writing a compiler for a subset of Java called J--, so I dont really want to get too into how it all works. But instead of calling javac HelloWorld.java I would call the equivalent j-- HelloWorld.java. javac works fine. You might say well the issue is with your code, but again it compiles and runs fine in Eclipse. So somewhere there seems to be a disconnect. Here is the Windows bash script if it helps:
set BASE_DIR=%~dp0
set j="%BASE_DIR%\..\"
set JAVA=java
set CPATH="%BASE_DIR%\..\lib\j--.jar;%BASE_DIR%\..\lib\spim.jar"
if "%CLASSPATH%" == "" goto runApp
set CPATH=%CPATH%;"%CLASSPATH%"
:runApp
%JAVA% -classpath %CPATH% jminusminus.Main "j--" %*
set JAVA=
set BASE_DIR=
set CPATH=
Edit
Thanks to Aubin, outputting the .jar file and comparing that with the class not found was how I was able to solve this conflict.
Usually Eclipse takes the sources from src and produces classes file into bin.
Try:
java -cp bin a.b.c.d.MyClass
To call your tool as j-- <args> you need to write a shell which embed the command:
java -cp bin a.b.c.d.MyClass $*