classpath

Run java without specifying classpath on the command line

半腔热情 提交于 2019-12-02 12:59:39
问题 I've specified the main class and classpath for a java program in the .jar file manifest, but occasionally I want to run a different class from the one specified by the Main-Class attribute. Can I get java to launch this class while still pulling the classpath from the manifest, so that I don't have to specify the whole thing on the command line with -cp ? 回答1: Just put the jar file on the command line with -cp; Java will then observe the classpath attribute within the manifest, even though

Java Audio Stream (mp3spi lib), UnsupportedAudioFileException

旧时模样 提交于 2019-12-02 12:33:18
I have seen multiple Stack Overflow questions regarding streaming MP3 streams (like Icecast). They all say to use the MP3SPI libraries, which I am. MP3SPI is for allowing support to audio/mpeg mime types. That's what my Icecast stream is. I have all three jar files in my classpath correctly, but while using the same code they provide in an example, I still get UnsupportedAudioFileException : javax.sound.sampled.UnsupportedAudioFileException: could not get audio input str eam from input URL at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java: 1153) at DJUtils.testPlay

cmd java not working [duplicate]

拜拜、爱过 提交于 2019-12-02 12:31:20
This question already has an answer here: Why can't I run my java Hello World program if it is inside a package? 3 answers I'm currently learning Java and the use of my command prompt as a compiler. But every time I execute the java command followed by my test class "Hello" I get the below error messages: Exception in thread "main" java.lang.NoClassDefFoundError: Hello (wrong name: hello/Hello) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:792) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net

Load Properties File in Singleton Class

六月ゝ 毕业季﹏ 提交于 2019-12-02 12:27:44
问题 I have seen this posted a couple of times and tried a few of the suggestions with no success (so far). I have a maven project and my properties file in on the following path: [project]/src/main/reources/META_INF/testing.properties I am trying to load it in a Singleton class to access the properties by key public class TestDataProperties { private static TestDataProperties instance = null; private Properties properties; protected TestDataProperties() throws IOException{ properties = new

Java Classpath Issue

一个人想着一个人 提交于 2019-12-02 11:54:06
I have two classes: MyApplication Library The Library has already been compiled into Library.class and the source code is no longer available. I am now trying to compile MyApplication from source. MyApplication depends on the Library. The Library has a package name of org.myCompany. I tried setting my classpath to the following: set CLASSPATH=C:\java\project\org\myCompany\Library.class;. which produced the following javac compiler error message: MyApplication.java:33: cannot find symbol symbol: class Library location: class MyApplication Library theLibrary = new Library(); So I changed my

NLTK Stanford Segmentor, how to set CLASSPATH

心不动则不痛 提交于 2019-12-02 11:54:02
I'm trying to use the Stanford Segementer bit from the NLTK Tokenize package. However, I run into issues just trying to use the basic test set. Running the following: # -*- coding: utf-8 -*- from nltk.tokenize.stanford_segmenter import StanfordSegmenter seg = StanfordSegmenter() seg.default_config('zh') sent = u'这是斯坦福中文分词器测试' print(seg.segment(sent)) Results in this error: I got as far as to add... import os javapath = "C:/Users/User/Folder/stanford-segmenter-2017-06-09/*" os.environ['CLASSPATH'] = javapath ...to the front of my code, but that didn't seem to help. How do I get the segmentor to

Base java classes still in the classpath during maven android build

自古美人都是妖i 提交于 2019-12-02 11:37:57
I'm having a rather strange problem caused by both the facts that the android java implementation differs from the sun java implementation and that the base java classes are still included in the classpath (all the way at the end) during a maven build of an android project. I think the solution is to not have the java classes on the classpath, but I can't seem to find a way to do this. Basically, there is a class called AbstractExecutorService in java.util.concurrent (in both android and java). The java class contains a couple methods called newTaskFor which I'd like to use in android, but the

executing java -jar via classpath vs in the jar file dir

谁说我不能喝 提交于 2019-12-02 11:24:05
After having used NetBeans to create a Java program call it Addition and then having successfully cleaned and built an Executable Jar File in a folder c:\Users\Ben\Doc\NetBeansProjects\Addition\dist WHY is it that when executing, from command prompt, c:\Users\Ben Java -Jar -cp "c:\Users\Ben\Doc\NetBeansProjects\Addition\dist" Addition.jar it does NOT work (i get 'unable to access jarfile Addition.jar) BUT if i use cd to change my current dir to c:\Users\Ben\Doc\NetBeansProjects\Addition\dist and THEN run 'java -jar Addition.jar' from there, the Addition program runs fine The -classpath

Applet code tags and class files

ぃ、小莉子 提交于 2019-12-02 11:01:08
问题 I just started writing Applets and I had some questions about the HTML applet tags with packages, and class files. I'll start with packages. I've been using Netbeans to code my applets, which includes a package automatically. The applet runs fine in the Netbeans applet viewer, and the HTML is displaying everything it should except the applet - there's just a white box that says "Error." When I re-compiled using Eclipse without the package, the HTML display the applet fine. I tried everything

referencing data files in jars

眉间皱痕 提交于 2019-12-02 10:07:18
My Java program references a lot of data files. I put them in a top level directory called data/, along with src/ and bin/. In Eclipse, references to data/ and ../data/ both seem to work. When I run it from the command line, only ../data/ works. When I put the bin/ and data/ directories in a jar and correctly set the entry point, it doesn't seem to know that I want it to access the data/ directory inside the jar. The only way I've been able to get it to work is by setting the references to ../data/ and placing the jar in the bin directory. This obviously doesn't do me any good, because it's