I am using kemulator to run j2me game (my own developed) when I try to run it i get an error which says "can not find MIDlet class plz check jad or use -midlet param"
Classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="res"/>
<classpathentry kind="con" path="J2MELIB"/>
<classpathentry kind="output" path="bin"/>
</classpath>
There is a package org/rhynn/ and there`s no such thing as a src folder in myGame.jar. I am using Eclipse ME to export this game.
actually there is no res or src folders in that jar. PS : Im new at those Manifest and other (except Java ME) so I dont know what to do.
A j2me application or game must have at least one class that extends MIDlet. Take this class full name, for example, org.rhynn.MyGameMIDlet and pass it to -midlet param.
try using ant and antenna to pack jar file
Related
I have a java application where i'm using embedded Tomcat servers,
which looks like this
Tomcat tomcat = new Tomcat()
I'm creating an embedded tomcat server here.
Problem statement
whenever there's an error it displays information on which tomcat version i'm using,
how to hide this in java?
i have a little idea that i need to override ServerInfo.properties, but how do i do this?
I'm not sure how we can do this in java, but if you are using any build scripts like ant / gradle for distribution purpose, we can write a task to override / harden the jar file, and replace the ServerInfo.properties file with the customized value whatever we need.
the code for ant build scripts would look like
<target name="override.tomcat">
<jar destfile="path/to/tomcat-embed-core-9.0.62.jar" update="true">
<fileset dir="src/"> <!-- folder where you keep the directory/file to raplace-->
<include name="org/apache/catalina/util/ServerInfo.properties"/> <!-- file to replace within directory path in side the jar-->
</fileset>
</jar>
</target>
and in gradle
task overRideTomcat(type: Jar) {
from(zipTree(file("path/to/tomcat-embed-core-9.0.62.jar"))) {
exclude '**/org/apache/catalina/util/ServerInfo.properties'
}
from('src/') {
include('/org/apache/catalina/util/ServerInfo.properties')
}
archiveName "tomcat-embed-core-9.0.62.jar"
}
make sure you have the modified ServerInfo.properties file under src directory in the same path as you have mentioned in the include statement.
Disclaimer: Ant Noob!
I'm trying to get the groovy task running in ant. Works so far:
<project>
<taskdef name="groovy"
classname="org.codehaus.groovy.ant.Groovy"
classpath="C:/Local/groovy-2.4.5/lib/groovy-ant-2.4.5.jar;C:/Local/groovy-2.4.5/lib/groovy-2.4.5.jar"/>
<echo message="Hello!"/>
<groovy>
println "Hello from Groovy!"
</groovy>
</project>
What I can't get behind (even reading this and related entries) is what I need to do to my Ant installation (Windows) to make the script run like so, without the taskdef or any other reference in my project specific build file:
<project>
<echo message="Hello!"/>
<groovy> <!-- Would be nice if I could treat this like a built-in -->
println "Hello from Groovy!"
</groovy>
</project>
You'll need to put all Groovy dependencies (groovy-ant.jar, groovy.jar, etc) on the classpath that is read by Ant. The easiest way is to store them under ANT_HOME/lib. Or you can pass them using the -lib option on the command line.
Then you would still have to tell Ant about the path of the antlib. You can use the antlib namespace mechanism described in the documentation page. You specify the package that contains the antlib.xml in the namespace URI, in this case org.codehaus.groovy:
<project xmlns:groovy="antlib:org.codehaus.groovy">
<echo message="Hello!"/>
<groovy:groovy>
println "Hello from Groovy!"
</groovy:groovy>
</project>
Note that you can still use taskdef without referencing the Jar file if it is placed (with its dependencies) in ANT_HOME/lib. You just reference the path of the antlib resource in the Jar. In this case you can do without the namespace URI:
<project>
<taskdef resource="org/codehaus/groovy/antlib.xml"/>
<echo message="Hello!"/>
<groovy>
println "Hello from Groovy!"
</groovy>
</project>
I am following this android developer page for the creation of custom attributes for an app. Everything is going fine and I am able to compile and see the results also.
But the part which is giving issue is IDE.Android Studio is complaining for unexpected namespace custom. Is there any way to disable/hide this error message? This is very annoying.
Even with this error, however, I am able to compile and run the app.
I followed follwing steps.
1) Created res/values/attrs.xml file and added
<?xml version="1.0" encoding="utf-8"?> <resources>
<declare-styleable name="FragArguments">
<attr name="max_allowed" format="integer"/>
<attr name="header" format="string"/>
</declare-styleable>
2) Trying to use in my mainlayout file's fragment tag
<LinearLayout xmlns:custom="http://schemas.android.com/apk/res"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1">
<fragment android:id="#+id/msg"
android:name="org.android.fragment.MessageFragment"
custom:max_allowed="85"
custom:header="#string/header"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
</LinearLayout>
3. Applying the custom attributes through code overriding the onInflate() method of fragment
#Override
public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) {
super.onInflate(activity, attrs, savedInstanceState);
TypedArray typedArray = activity.obtainStyledAttributes(attrs, R.styleable.FragArguments);
max_allowed = typedArray.getInt(R.styleable.FragArguments_max_allowed, -1);
header = typedArray.getString(R.styleable.FragArguments_header);
typedArray.recycle();
}
I just figured out the solution.
The issue ID MissingPrefix tells lint to only scan for XML attributes that are missing the Android namespace prefix.So we can do this two ways:--
Canissue the following command to scan the files under the main project directory and its subdirectories.
lint --check MissingPrefix myproject
In android studio create a lint.xml file with following content and add in app directory.
<?xml version="1.0" encoding="utf-8"?>
<lint>
<issue id="MissingPrefix" severity="ignore"/>
</lint>
Thanks to #Nicks answer. You can also add following lines to the build.gradle file, inside android {} scope:
lintOptions {
disable 'MissingPrefix'
}
Eclim daemon is running.
:PingEclim yields
eclim 2.3.2
eclipse 4.3.1
File: Foo.java
public class Foo {
public static void main(String[] args) {
System.out.print("Foo");
}
}
By running :Java, I am presented with the error
java.lang.RuntimeException: Required setting 'org.eclim.java.run.mainclass' has not been set.
Now, I know I can manually set the mainclass in the project settings, but this used to work just by running :Java. Additionally I can add that running :Java % is not working either. It simply seems incapable of detecting my main function.
Update
Included the output of :Java % below.
Error: Could not find or load main class .Foo
[java] Java Result: 1
Update 2
It seems Eclim sets the main class the first time it detects and runs a Main function inside a Project. After that, trying to manually run another class containing a main function will result in the above error. Not sure how to work around it, but it should really be possible to not be locked to the class that is run first.
I had the same problem too. Then I found out that if the main class is included in a package, you have to use the full qualified class name. For example, if your main class starts with:
package a.b.c;
Then use the setting:
org.eclim.java.run.mainclass = a.b.c.Foo
After that, it should work fine.
i am having the same problem . i compared two projects one was made by eclim and other in eclipse and found .
.classpath file on :
eclipse
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
eclim
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
so i tried to change it to the one like eclipse and it worked .
I'm developing a JavaFx 2.0 application using Netbeans 7.
The main application references another class library project added by rightclicking the 'Libraries' folder and selecting 'Add Project...'. Executing the application from netbeans works fine.
When deploying it to a jar file by 'Clean and build' and trying to execute it via console with
java -jar TestApp.jar
I get
Exception in thread "JavaFX-Launcher" java.lang.NoClassDefFoundError: net/pmoule/SomeClass
...
The dist/lib folder of my application contains the referenced library. So IMHO everything should be fine. Looking at the Manifest.MF contained in my application jar I get this
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.6.0_23-b05 (Sun Microsystems Inc.)
Implementation-Vendor: pmoule
Implementation-Title: TestApp
Implementation-Version: 1.0
Main-Class: com/javafx/main/Main
JavaFX-Application-Class: testapp.TestApp
JavaFX-Version: 2.0
Where is my class path? How do I get Netbeans to add the correct classpath?
I tried adding it manually to the Manifest.MF by editing the one contained in the jar
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.6.0_23-b05 (Sun Microsystems Inc.)
Implementation-Vendor: pmoule
Implementation-Title: TestApp
Implementation-Version: 1.0
Class-Path: lib/MyLib.jar //THIS IS NEW
Main-Class: com/javafx/main/Main
JavaFX-Application-Class: testapp.TestApp
JavaFX-Version: 2.0
No success and same error.
All samples delivered with the JavaFX 2.0 SDK work by doubleclicking in WindowsExplorer or from the console by entering e.g.
java -jar PathAnimation.jar
But not any of these examples makes a reference to an external jar.
Some research lead me to this question: Netbeans JavaFX 2.0 Application
But without any solution so far.
Thanks for any help!
Found a working solution by myself.
All the external libraries in the dist/lin folder had a size of 0kb. So the exception was correct, of course.
To get my application running I did the following in the project's jfx-impl.xml:
Add the classpath to manifest.mf
<fxjar destfile="${jfx.deployment.dir}/${jfx.deployment.jar}" applicationClass="${main.class}" >
<fileset dir="${build.classes.dir}"/>
<manifest>
<attribute name="Implementation-Vendor" value="${application.vendor}"/>
<attribute name="Implementation-Title" value="${application.title}"/>
<!-- NEW --> <attribute name="Class-Path" value="${jar.classpath}"/> <!-- NEW -->
<attribute name="Implementation-Version" value="1.0"/>
</manifest>
</fxjar>
Create an output dir for web deployment
<property name="jfx.deployment.web.dir" location="${jfx.deployment.dir}/web" />
<mkdir dir="${jfx.deployment.web.dir}" />
Set output dir for fxdeploy task
<fxdeploy width="${jfx.applet.width}" height="${jfx.applet.height}"
outdir="${jfx.deployment.web.dir}" <!-- NEW DIR -->
embedJNLP="true"
outfile="${application.title}">
<info title="${application.title}"
vendor="${application.vendor}"/>
<application name="${application.title}"
appclass="${main.class}"/>
<resources type="eager">
<fileset dir="${jfx.deployment.web.dir}"> <!-- NEW DIR -->
<include name="${jfx.deployment.jar}"/>
<include name="lib/*.jar"/>
<exclude name="**/jfxrt.jar"/>
</fileset>
</resources>
</fxdeploy>
Now, I can deploy my desktop application and execute ist via doubleclick from windows explorer or by entering
java -jar TestApp.jar
There still exists some issue with the content of my newly created web-dir.
The TestApp.jar ist not copied zo dist/web
The referenced external jars are not copied to dist/web
This is fine for me and will be fixed some time later.
Hope this helps anyone else.
In Netbeans, under project => properties => Build => Packaging, did you check "Copy Dependent Libraries" ?
You need to tell the fx:jar task what your classpath dependencies are:
<fxjar destfile="${jfx.deployment.dir}/${jfx.deployment.jar}" applicationClass="${main.class}" >
<fileset dir="${build.classes.dir}"/>
<manifest>
<attribute name="Implementation-Vendor" value="${application.vendor}"/>
<attribute name="Implementation-Title" value="${application.title}"/>
<attribute name="Implementation-Version" value="1.0"/>
</manifest>
<!-- Setup the classpath for the generated .jar here -->
<fx:resources>
<fx:fileset type="jar" dir="lib" includes="MyLib.jar"/>
</fx:resources>
</fxjar>
You also need to use fx:resources tag in your fx:deploy task instead of just resources. That should resolve the last two problems left in your answer.