Phuc Bui

Greenhorn
+ Follow
since Feb 19, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Phuc Bui

Peter Johnson wrote:The problem is that you don't understand how packages relate to classpaths. You should have cd'ed to the D:\workspaces\Java_app\antSample\src directory and then run "java app.main.Main", then it would have found the class. (Note that the javac compiler deals with files within directories, whereas the java runtime deals with classes within classpaths, and packages are part of the class name.)

But that is not the same issue you ran into with Ant because the way your build script is set up, doing "ant compile jar run" works for me.



Actually, I do not understand ant very well so I have returned to simple ant and it worked :-)
Thanks for your support, I will try more complex ant
13 years ago
I found the problem that does not concern Ant
I have a simple Main.java as below


Stand at D:\workspaces\Java_app\antSample\src\app\main that contains the file Main.java



Remove package app.main; in the source then build and run again



So what is the problem here

By the way, would you mind giving a simple ant with external library
13 years ago


Yes, I want to use an external library.
But it even did not work with "System.out.println()"
13 years ago

Peter Johnson wrote:Is the file hierarchy you posted correct, or is there a typo? Specifically, is the Main class source at antSample/app/main/Main.java or at antSample/app.main/Main.java? Please post the contents of the JAR file by running "jar -tf path/to/antSample.jar"

You didn't show enough of the build.xml. What is ${mainclass}? Where are you compiling your source files to? It is that directory that you should use for <jar ... basedir="xxx"> (the xxx should be the directory into which the class files were compiled, not ${basedir}).



Thanks for your reply.
Here is the hierarchy


This is the contents of the JAR file


And this is ant content


And all the sample I've uploaded here
http://www.mediafire.com/?cm345ypfht6hsdf


Thanks for your support :-)
13 years ago
I have a simple sample to get started with Ant such as show a Hello frame.
My project structure is:



And ant.xml file like that:



It ran OK until target "run" when this error is thrown out:
Buildfile: D:\workspaces\Java_app\antSample\ant.xml
run:
[java] java.lang.NoClassDefFoundError: app/main/Main
[java] Caused by: java.lang.ClassNotFoundException: app.main.Main
[java] at java.net.URLClassLoader$1.run(Unknown Source)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(Unknown Source)
[java] at java.lang.ClassLoader.loadClass(Unknown Source)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
[java] at java.lang.ClassLoader.loadClass(Unknown Source)
[java] at java.lang.ClassLoader.loadClassInternal(Unknown Source)
[java] Could not find the main class: app.main.Main. Program will exit.
[java] Exception in thread "main"
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 352 milliseconds

I have try to modify Ant Runtime as some intructions found on internet
Window > References > Ant > Runtime > Point to Ant Home to /eclipse_home/plugins/org.apache.antXXXX
Add tool.jar from JDK

But it's still getting stack.

Thanks for anysuggestion :-)
13 years ago
Dear,
I followed this instruction (download file here) and did well.
Hope it helps :-)

Phuc Bui
15 years ago
Dear all,
I have changed a Struts app and JSF app to a portlet successfully by using bridges from this site http://portals.apache.org/bridges/
But I do not know how to change a JSP/Servlet app to portlet, I do not see any bridge, or instruction to do that :-(
Would you please tell me how to do that ?

Thanks a lot.
Phuc Bui
15 years ago
Dear all,
My application used log4j and jexcelapi.
It's just a simple application, but I do not know how to pack it into jar file that includes referenced library ?
When I export it into jar file and run it, it said"
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Layout

Thanks a lot,
Phuc Bui
Oh, sorry !!! That's silly
I have a mistake, that I can read it but can not write because I do not have right to do this.
I try it again with admin account and it's okay
Thanks for your help
Phuc Bui
15 years ago
Dear all,
I have a simple example about Java IO.
I want to list the name of file and sub-directory of a given directory.
It's easy when I work with a directory from hard disk,
but I can not deal with external storage devices (such as CD and USB)
Please tell me how to solve this problem ???

Thanks so much,
Phuc Bui
15 years ago
Hi,
I have already had getter and setter for UploadedFile object

Tomahawk is what creates that object - not Spring.


So you mean, I do not need to declare anything about UploadedFile in Spring ?
But how about faces-config

How should I do with <managed-property> for the property uploadedFile ?

Thanks,
Phuc Bui
15 years ago
JSF
Dear,
Would you please tell me how to define UploadedFile object in Spring >
I tried this

and my bean using it


But the UploadedFile object is always null ?

Thanks,
Phuc Bui
15 years ago
JSF
Thanks Tim,
That's helpful
15 years ago
JSF
Dear all,
I used <t:inputFileUpload > to upload file with JSF.
but I don't know the location of uploaded file ?
My problem is: I need to read a data from an excel file. So I need to upload an excel file to server
then read the its content. But I do not know the location to read.
Would you please show me the solution
Thanks so much
Phuc Bui
15 years ago
JSF
Dear all,
Is there anyway else to go to Struts Action (include parameter) with a hyperlink ? Except struts tag <html:link>
By the way, how can I include 2 or more parameters with <html:link> ? If I use <a href="">
I can include many parameters like url?id=123&name=abc for example
Thanks
Phuc Bui
15 years ago