|
Is it running on a Linux backend? If they are running on Windows, you could get away with developing in .NET (it costs the client nothing wrt licenses and can easily connect to MySQL). It's also possible to hook ASP.NET into Apache.
|
|
|
|
|
Good day,
I have been battling with this for a while now, and have been at previous forums regarding this problem, all leading to non-working solutions.
Note: I am using NetBeans IDE 7.0 and java 1.6.0_25 on a Windows XP SP 3 machine.
I want to run the application without using the command line, although using the commandline gives me exactly the same error.
I have tried numerous other forums, even consulting the java forums, but all to no avail. Most of the forums make mention about editing the build file, but not being a java guru (c# is more my thing), I have no idea what to do! (I am including my build.xml as well as the manifest.mf file which is contained within the .jar file for anybody who wants to have a peek at it.)
When I run the application from within NetBeans, everything works fine.
I thought that maybe something went wrong with my java installation, but (fortunately?) I had a BSOD, so I was forced to format my system, which then received a very fresh installation of NetBeans as well as java, but the error still remains.
If you could help me, it would be much appreciated!
Just ask if you need additional files or information,
Kind regards,
Rossouw
EDIT: When I run the application from within NetBeans, it informs me that it cannot find some of my packages, but when I first build and clean it, and then run it, it runs fine.
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="OmniIDE" default="default" basedir=".">
<description>Builds, tests, and runs the project OmniIDE.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="OmniIDE-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>
manifest.mf (contained within the .jar file)
Note: The format of the contents of this file is exactly the format of the original file's contents.
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.6.0_25-b06 (Sun Microsystems Inc.)
Main-Class: omniide.OmniIDEApp
Class-Path: lib/appframework-1.0.3.jar lib/swing-worker-1.1.jar lib/Ab
soluteLayout.jar lib/swing-layout-1.0.4.jar lib/beansbinding-1.2.1.ja
r
modified on Monday, July 11, 2011 5:01 AM
|
|
|
|
|
You should not have to edit the build.xml for your java app to work from the console. Since it is working from Netbeans I'm presuming that all your code is correct and compiled properly without problems.
Netbeans will create a .jar file in the build directory of the project. You will have to find that to be able to start your main class via command line. Once you located it you can start the your jar from the command line as follows:
java -cp myjar.jar;mylib1.jar;mylib2.jar com.classpackage.MyClass
Where you need to replace the last parameter with the full class name of the class you are trying to start (so including the full package name). The files after -cp are the libraries you need for your application to run. This would at least include the jar file generated by Netbeans, but also any library that you have included in the project.
|
|
|
|
|
It could even be simpler. I'm using Eclipse, but also Netbeans should have some "Extract Project" option. There you can select on the type of application you need - Netbeans should do the rest of the job. The extracted stuff should inculde a starter in form of *.exe .
regards Torsten
I never finish anyth...
|
|
|
|
|
Gerben Jongerius wrote: java -cp myjar.jar;mylib1.jar;mylib2.jar com.classpackage.MyClass
Unfortunately this did not work.
Here is my directory structure:
-dist
--OmniIDE.jar
--lib
---AbsoluteLayout
---appframework-1.0.3.jar
---beansbinding-1.2.1.jar
---swing-layout-1.0.4.jar
---swing-worker-1.1.jar
So I CMDd the following:
java -cp OmniIDE.jar;lib\AbsoluteLayout.jar;lib\appframework-1.0.3.jar;lib\beansbinding-1.2.1.jar;lib\swing-layout-1.0.4.jar;lib\swing-worker-1.1.jar com.omniide.OmniIDEApp
And the exception (all continuous):
Exception in thread "main" java.lang.NoClassDefFoundError: com/omniide/OmniIDEApp
TorstenH. wrote: Netbeans should have some "Extract Project" option.
Unfortunately, no. There are two extract options:
-Extract Interface
-Extract Superclass
Converting from NetBeans to Eclipse would not be an option though...
Thanks,
Rossouw
|
|
|
|
|
Where is the class file com/omniide/OmniIDEApp within the items listed in your classpath, and are you sure the spelling is correct?
The best things in life are not things.
|
|
|
|
|
I'm not sure I am following... (Java isn't my strongpoint.)
I don't set any environment variables myself, and I don't set any classpath myself either. I figured that the jar file (with the manifest and build file), would handle that for me.
|
|
|
|
|
RossouwDB wrote: I don't set any classpath myself
The -cp option followed by a list of .jar files is your classpath. You need to check that the class you are trying to invoke actually exists within one of your .jar files and is under the specified path (i.e. package and class).
The best things in life are not things.
|
|
|
|
|
Richard MacCutchan wrote: -cp option followed by a list of .jar files is your classpath
crud, I knew but forgot that! Now I follow
The omniide is my "main" package, and the omniIDEApp is the entrypoint of my application. Everything is spelled correctly since I have even copied it as is from my Manifest file, but to no avail.
Here is the actual code for my entrypoint class:
package omniide;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
public class OmniIDEApp extends SingleFrameApplication {
@Override protected void startup() {
show(new OmniIDEView(this));
}
@Override protected void configureWindow(java.awt.Window root) {
}
public static OmniIDEApp getApplication() {
return Application.getInstance(OmniIDEApp.class);
}
public static void main(String[] args) {
launch(OmniIDEApp.class, args);
}
}
This code is generated by NetBeans when the project is created.
I am stumped as to the cause of this error!
|
|
|
|
|
Are you sure about the com. prefix in your class name:
java -cp OmniIDE.jar;lib\AbsoluteLayout.jar;lib\appframework-1.0.3.jar;lib\beansbinding-1.2.1.jar;lib\swing-layout-1.0.4.jar;lib\swing-worker-1.1.jar com.omniide.OmniIDEApp
[edit]You can check this by running the command jar -tvf against the jar file that contains (or should contain) your main class.[/edit]
[edit2]Or you could execute the .jar file directly by
java -cp lib\AbsoluteLayout.jar;lib\appframework-1.0.3.jar;lib\beansbinding-1.2.1.jar;lib\swing-layout-1.0.4.jar;lib\swing-worker-1.1.jar -jar OmniIDE.jar
assuming your main class is in the OmniIDE.jar file.
[/edit2]
The best things in life are not things.
|
|
|
|
|
I have tried omitting it, but still doesn't work.
|
|
|
|
|
See my edits to my previous message.
The best things in life are not things.
|
|
|
|
|
Richard MacCutchan wrote: running the command jar -tvf against the jar file that contains (or should contain) your main class
Confirms that com. is not needed, and that my main class is contained within the OmniIDE.jar file.
Richard MacCutchan wrote: Or you could execute the .jar file directly
Does not work.
|
|
|
|
|
RossouwDB wrote: Does not work.
Really not a helpful definition of a problem!
What's the output of the jar -tvf command? Also what happens when you try with the -jar option? Please show exact commands and exact output in all cases.
PS: I do not use NetBeans but Eclipse, and I know there are some bits of framework stuff that NetBeans adds to your package so it may well be that you cannot run the final package outside of the NetBeans environment. However, why that would be so is anyone's guess.
The best things in life are not things.
|
|
|
|
|
I don't know how and why, but now everything is working!!
I was typing away, and doing a clean + build like I normally do,and when I tried to run it again, it bombarded me with error messages indicating that a lot of my packages could not be found!
Stumped, I cleaned and built it a couple of times, but failed miserably when I want to run it (really odd, since it was running successfully a couple of seconds ago.)
So, I located the "broken" package, and renamed it to the package NetBeans expected. Cleaned and built it, ran it - it worked.
So i though I might give executing the application a shot, and it worked!
It's really odd though, since NetBeans should have complained right from the start, but for some reason, it didn't.
Anyway, thanks for your help.
|
|
|
|
|
|
Sorry, what?
The best things in life are not things.
|
|
|
|
|
Wait, what???? Dude, you ok? Did I say this is homework?????
|
|
|
|
|
This is no simple Java homework
Netbeans should provide a functionality to export your project in a proper way.
There is no need to build some strange stuff. That's time waisted.
regards Torsten
I never finish anyth...
|
|
|
|
|
TorstenH. wrote: This is no simple Java homework
It's NOT HOMEWORK. It's a project I am working on...
TorstenH. wrote: Netbeans should provide a functionality to export your project in a proper way.
Clearly it's not always working so well, but I would still use NetBeans.
TorstenH. wrote: There is no need to build some strange stuff
Why not??? What isn't strange in live? Clearly you are.... So am I!
TorstenH. wrote: That's time waisted
No, actually it's not! I have learned something from this entire experience, so I would not say it's time wasted!
Note:If you don't want to help people, and you want to attack them for some strange and peculiar reason, rather keep quiet! (Go read the guidelines: Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers!)
|
|
|
|
|
..That's what I said - this does not look like a simple homework-project that can be simply launched from the command line.
Why would you even want to work on the command line? All you're asking for is to run it outside of your IDE.
So I recommend to export the project in the given way and that's it. Netbeans will do what is is supposed to do - build your application.
No need to waste hours of time on fuzzy command line arguments. Better get a nice ice cream and watch Netbeans do the build
regards Torsten
I never finish anyth...
|
|
|
|
|
When we assign a subclass object to its superclass reference then the superclass reference can only access the methods that are in the superclass, it can't even the aceess its overridden methods in subclass.
if the above lines are true then how the following code can works ...
class a
{
int x;
void show()
{
System.out.println(x);
}
}
class b extends a
{
void show()
{
System.out.println("in subclass");
}
void show2()
{
System.out.println("in show2");
}
}
class Main
{
public static void main(String args[])
{
b bRef=new b();
a aRef=new b(); // why this line prints "in subclass". How a reference access the subclass?
aRef.show();
bRef.show2();
}
}
|
|
|
|
|
See the note about implicit casting in this page[^] of the Java Tutorials.
Also please put your code between <pre> tags for proper formatting.
The best things in life are not things.
|
|
|
|
|
gateway23 wrote: a aRef=new b(); // why this line prints "in subclass". How a reference access the subclass?
A reference points to an object.
Your reference points to an object of type 'b'.
|
|
|
|
|
gateway23 wrote: a aRef=new b(); // why this line prints "in subclass". How a reference access
the subclass?
It is because eventhough you have declared aRef to be of class 'a', it acutally holds an instance of class 'b' at runtime. That is what Polymorphism is all about. That's not a problem, that's the expected behavior.
|
|
|
|