CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Apr 2012
    Location
    Slovenia
    Posts
    259

    compile a program in terminal with .jar

    I created Myproject folder. Inside I have 3 folders:
    /lib
    /src
    /bin

    Inside src there is a .java file:

    Code:
    	public class hello_world{
    	     
    	     public static void main(String[] args){
    	        System.out.println("Hi, from hello_world");
    	     
    	        seba.st.hello_world_package test1 = new seba.st.hello_world_package();
    	 
    	        test1.packFunc();
    	    }
    	 
    	}
    inside lib is a .jar file which I created from this .java file:


    Code:
    	package seba.st;
    	 
    	public class hello_world_package{
                
    	    public void packFunc(){
    	     
    	        System.out.println("hi from pack_func!");
    	    }	 	
         }
    I am trying to run this program from terminal with this command
    Code:
    	javac -d bin -sourcepath src -cp lib/packEx.jar src/hello_world.java
    and I get this error:
    Code:
    	src/hello_world.java:11: error: cannot find symbol
    	        test1.packFunc();
    	             ^
    	  symbol:   method packFunc()
    	  location: variable test1 of type hello_world_package
    	1 error

    What am I doing wrong ? How can I compile and run this program from terminal?
    Last edited by flex567; March 13th, 2015 at 05:37 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured