I'm running the following command through CMD:
"C:\Program Files\Java\jdk1.7.0_51\bin\idlj.exe" -fall hello.idl
The hello.idl file is located in the same folder as the idlj.exe file and contains the following
module HelloApp
{
interface Hello
{
string sayHello();
oneway void shutdown();
};
};
However, I am receiving the following error upon execution of the above command:
java.io.FileNotFoundException: hello.idl (The system cannot find the file specified)
Can you please advise what is wrong here and the solution. Should the idl file be located in another folder?
Thanks
The file hello.idl should be in your current directory.
So if you have the idl file in the same dir like idlj.exe, then you should go to directory C:\Program Files\Java\jdk1.7.0_51\bin and execute the command: idlj.exe -fall hello.idl
Related
I have my jar app with the name myApp.jar, and I have custom application.properties in the same folder in Linux. /etc/myApp
When I start java -jar /etc/myApp/myApp.jar in the folder /etc/myApp everything work well. But I have a problem when I want to start this command out of this folder(In my bash script).
I have an error:
Exception in thread "main" java.io.FileNotFoundException:
application.properties (No such file or directory)
I turned with:
java -jar /etc/myApp/myApp.jar -Dspring.config.location=file:/etc/myApp/application.properties
and
java -jar /etc/myApp/myApp.jar --spring.config.location=/etc/myApp/application.properties
And I have the same error.
This is part where I using the application.properties
Properties myProperty = new Properties();
myProperty.load(new FileInputStream("application.properties"));
MailBuilder mail = new MailBuilder(myProperty);
I have a jar file named- ParseCSV-0.0.1-SNAPSHOT.jar and the contents of it are -
META-INF/
META-INF/MANIFEST.MF
foo/
foo/ReadCSV.class
META-INF/maven/
META-INF/maven/Test/
META-INF/maven/Test/ParseCSV/
META-INF/maven/Test/ParseCSV/pom.xml
META-INF/maven/Test/ParseCSV/pom.properties
The main class is ReadCSV.class and it takes a CSV file (C:\Testting\ValidaResults.csv) as an input parameter. I am trying to execute the jar file from the command promt by running the following command-
java -jar . ParseCSV-0.0.1-SNAPSHOT.jar "C:\Testting\ValidationResult.csv"
But I am getting an error saying-
Error: Could not find or load main class foo.ReadCSVTest
What is going wrong here.
Why do you have a . between jar and ParseCSV..?
Try this first:
java -jar ParseCSV-0.0.1-SNAPSHOT.jar "C:\Testting\ValidationResult.csv"
If this does not work, then try:
java -cp ParseCSV-0.0.1-SNAPSHOT.jar;. foo.ReadCSV "c:\Testting\ValidationResult.csv"
If this works, then i would inspect the META-INF/MANIFEST.MF file to figure out what the classpath is like, and what the value of Main-Class is. It seems to be running ReadCSVTest instead of ReadCSV.
Your JAR file includes foo/ReadCSV.class, but your MainClass is set to foo.ReadCSVTest. You'll need to fix your Main-Class attribute in META-INF/MAINIFEST.MF
I built a project in eclipse that uses a txt file. the file is located in the main folder project.
I get the file name as argument via command line, and I get FileNotFoundException. I try to use Scanner Object and get the file name as input from eclipse.. and it's worked. (I insert only the file name : file.txt . not the full path)
so why via the eclipse it's work and with command line not?
thank you!
this is the exception:
java.io.FileNotFoundException: bigMaze.txt (The system cannot find the file spec
ified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileReader.<init>(FileReader.java:72)
at BFS.BFS.readFile(BFS.java:43)
at BFS.BFS.InsertMaze(BFS.java:57)
at BFS.BFS.StartMain(BFS.java:16)
at search.main(search.java:20)
Exception in thread "main" java.lang.NullPointerException
at BFS.BFS.InsertMaze(BFS.java:62)
at BFS.BFS.StartMain(BFS.java:16)
at search.main(search.java:20)
If you're running from the command line, try placing the file in the same directory as the .class file
ProjectRoot
bin
file.txt
program.class
src
If the program is running from eclispe, then the file should go where you originally had it. directly under the project root.
This is all considering your running the program with String filename = "file.txt";
I think the problem is regarding pathname of your txt file. In case of command prompt you have to provide full path like: "MyComputer://D/yourFile.txt" but using eclipse you can give just "D://yourFile.txt". It will work.
I'm trying to run a complied class with the command:java SocketTest in current directory.
But something wrong:
Exception in thread "main"
java.lang.NoClassDefFoundError:SocketTest(wrong
name:socket/SocketTest)...
here is my classpath AND path configration in windows XP:
JAVA_HOME:
C:\Program Files\Java\jdk1.7.0_25\
classpath:
.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
path:
%JAVA_HOME%\jre\bin;C:\Program Files\Java\jdk1.7.0_25\bin;C:\Ruby187\bin;H:\Program Files\ARM\ADSv1_2\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%JAVA_HOME%\bin;C:\Program Files\Microsoft SQL Server\80\Tools\BINN
I think the .; has been carefully written,so I'm not sure what's wrong with the java command. Someone help,please!
The error message has pointed out you need to put the your class to the corrected package socket. So you need to create folder with name socket and then put your SocketTest.class to this folder and run the following command (under the parent folder of socket):
java socket.SocketTest
I've a java program as shown below:
package com.abc.myproject;
import java.util.*;
class test {
public static void main(String[] args)
{
ResourceBundle rb = ResourceBundle.getBundle("mybundle");
String propertyValue = rb.getString("name");
System.out.println("propertyValue="+propertyValue);
}
}
I've this program located under C:\testing\code\src\com\abc\myproject\test.java
And, I've kept mybundle.properties under C:\testing\code folder.
mybundle.properties contain one line:
name=Mike
When I run the program from command prompt as shown below, it runs perfectly fine:
C:\testing\code\src>java -cp .;c:\testing\code com.abc.myproject.test
propertyValue=Mike
Now, I created Jar file xyz.jar containing only test.class & kept this Jar in C:\testing directory & the manifest of jar contains below:
Manifest-Version: 1.0
Created-By: 1.7.0_05 (Oracle Corporation)
Main-Class: com.abc.myproject.test
In the same directory C:\testing, I kept mybundle.properties & then tried to run jar with below commands:
java -cp .;c:\testing -jar xyz.jar
But it fails to load mybundle resource & throws error:
Exception in thread "main" java.util.MissingResourceException: Can't find bundle
for base name scheduler, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
at java.util.ResourceBundle.getBundleImpl(Unknown Source)
at java.util.ResourceBundle.getBundle(Unknown Source)
at com.abc.myproject.test.main(test.java:8)
I have to keep the mybundle.properties out side of Jar since we should be able to make changes in this file without having to redeploy the Jar.
Can any one please help me in fixing this issue?
Thanks!
java -cp .;c:\testing -jar xyz.jar
You cannot add to the classpath when using -jar. $CLASSPATH and -cp are ignored, and it will only use the classpath in the jar manifest.
What you can do is run your class like this:
java -cp .;c:\testing;xyz.jar com.abc.myproject.test