Results 1 to 2 of 2
- 12-05-2011, 03:40 AM #1
Member
- Join Date
- Mar 2010
- Posts
- 19
- Rep Power
- 0
launching application with java command line
Hi all,
I have been stuck doing this for few hours, i appreciate if someone can help me out!
I have two classes;
andJava Code:package test; public class TestingClient { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println(new Client().getCounter()); } }
I'm running ubuntu 11.10 and i have tested java and javac and they work.Java Code:package test; class Client { private int counter; Client(){ counter = 10; } public int getCounter() { return counter; } }
The following is my directory structure:
the current directory is srcJava Code:home/workspace/Testing/src/test/TestingClient.java home/workspace/Testing/src/test/Client.java
I used:
and it created the class file TestingClient.class inside src/testJava Code:javac TestingClient.java
and it created the class file Client.class inside Testing/classesJava Code:javac -d ../classes Client.java
now when i use:
i get this error message:Java Code:java -cp ../classes test.TestingClient
Error: Could not find or load main class test.TestingClient
what i'm doing wrong?
PS: later on, i put both classes inside the bin folder inside the project folder and java command line worked! could it be the -cp?
- 12-05-2011, 01:09 PM #2
Re: launching application with java command line
The TestingClient class is in the test package. The java program will look in a test folder for the TestingClient.class file.
You say that the TestingClient.class file is in the classes folder, not a test folder.
The classpath for the java command should point to the folder containing the test folder. The test folder should contain the TestingClient.class file.
Similar Threads
-
Open a URL and read it line by line (Works in Eclipse but not from Command Line)
By rosco544 in forum NetworkingReplies: 16Last Post: 09-17-2011, 02:41 AM -
How do you use the Mac command line for Java?
By java beginner in forum New To JavaReplies: 16Last Post: 05-07-2011, 04:34 AM -
tracing java application line by line using netbeans
By chandrasekhar123 in forum NetBeansReplies: 1Last Post: 08-03-2010, 02:46 PM -
Formatting java command line output - Multi line string
By dricco in forum New To JavaReplies: 2Last Post: 07-02-2010, 02:20 PM -
Unable to execute command line command in java
By LordSM in forum New To JavaReplies: 1Last Post: 08-08-2007, 12:23 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks